Refresh wallet after local node actions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user