Refresh wallet after local node actions
build / Build Windows wallet (push) Has started running
build / Build Linux wallet (push) Has been cancelled

This commit is contained in:
Codex Bot
2026-04-19 18:27:10 +02:00
parent 9c5adb0e94
commit ed43484fe4
2 changed files with 35 additions and 3 deletions
+4 -1
View File
@@ -50,7 +50,10 @@ class WindowsLocalNodeService implements LocalNodeService {
@override
Future<bool> restart({LocalNodeConfig? config}) async {
final effective = _resolveConfig(config);
await stop();
final stopped = await stop();
if (!stopped) {
return false;
}
return _startNode(effective);
}
+31 -2
View File
@@ -300,7 +300,7 @@ class _LocalNodeControlsState extends ConsumerState<_LocalNodeControls> {
children: [
ElevatedButton.icon(
onPressed: canStart
? () => _runAction(
? () => _runNodeAction(
action: () => localNodeService.start(config: _nodeConfig),
successMessage: l10n.localNodeStartSuccess,
failureMessage: l10n.localNodeStartFailure,
@@ -311,7 +311,7 @@ class _LocalNodeControlsState extends ConsumerState<_LocalNodeControls> {
),
OutlinedButton.icon(
onPressed: canRestart
? () => _runAction(
? () => _runNodeAction(
action: () => localNodeService.restart(config: _nodeConfig),
successMessage: l10n.localNodeRestartSuccess,
failureMessage: l10n.localNodeRestartFailure,
@@ -376,6 +376,35 @@ class _LocalNodeControlsState extends ConsumerState<_LocalNodeControls> {
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
Future<void> _runNodeAction({
required Future<bool> Function() action,
required String successMessage,
required String failureMessage,
}) async {
await _runAction(
action: () async {
final ok = await action();
if (!ok || !mounted) {
return ok;
}
final config = ref.read(appConfigControllerProvider);
final nodeConfig = config.nodeConfig;
final walletState = ref.read(walletControllerProvider);
if (walletState.walletInfo != null && nodeConfig.mode == NodeMode.local) {
try {
await ref.read(walletControllerProvider.notifier).connectNode(nodeConfig);
await ref.read(walletControllerProvider.notifier).syncNow();
} catch (_) {
// Keep action successful if daemon started; sync errors surface through wallet state.
}
}
return ok;
},
successMessage: successMessage,
failureMessage: failureMessage,
);
}
Future<void> _showNodeSettingsDialog(BuildContext context) async {
final l10n = context.l10n;
final controller =