diff --git a/lib/services/coins/banano/banano_wallet.dart b/lib/services/coins/banano/banano_wallet.dart index a0ad8f7ee..8511f5599 100644 --- a/lib/services/coins/banano/banano_wallet.dart +++ b/lib/services/coins/banano/banano_wallet.dart @@ -304,6 +304,9 @@ class BananoWallet extends CoinServiceAPI @override Future exit() async { _hasCalledExit = true; + timer?.cancel(); + timer = null; + stopNetworkAlivePinging(); } @override @@ -767,6 +770,22 @@ class BananoWallet extends CoinServiceAPI coin, ), ); + + if (shouldAutoSync) { + timer ??= Timer.periodic(const Duration(seconds: 30), (timer) async { + Logging.instance.log( + "Periodic refresh check for $walletId $walletName in object instance: $hashCode", + level: LogLevel.Info); + + await refresh(); + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "New data found in $walletId $walletName in background!", + walletId, + ), + ); + }); + } } catch (e, s) { Logging.instance.log( "Failed to refresh banano wallet $walletId: '$walletName': $e\n$s", diff --git a/lib/services/coins/nano/nano_wallet.dart b/lib/services/coins/nano/nano_wallet.dart index 1f525d86d..1e783bf5f 100644 --- a/lib/services/coins/nano/nano_wallet.dart +++ b/lib/services/coins/nano/nano_wallet.dart @@ -310,6 +310,9 @@ class NanoWallet extends CoinServiceAPI @override Future exit() async { _hasCalledExit = true; + timer?.cancel(); + timer = null; + stopNetworkAlivePinging(); } @override @@ -779,6 +782,22 @@ class NanoWallet extends CoinServiceAPI coin, ), ); + + if (shouldAutoSync) { + timer ??= Timer.periodic(const Duration(seconds: 30), (timer) async { + Logging.instance.log( + "Periodic refresh check for $walletId $walletName in object instance: $hashCode", + level: LogLevel.Info); + + await refresh(); + GlobalEventBus.instance.fire( + UpdatedInBackgroundEvent( + "New data found in $walletId $walletName in background!", + walletId, + ), + ); + }); + } } catch (e, s) { Logging.instance.log( "Failed to refresh nano wallet $walletId: '$walletName': $e\n$s",