diff --git a/lib/services/coins/banano/banano_wallet.dart b/lib/services/coins/banano/banano_wallet.dart index 1240ac446..d44075d09 100644 --- a/lib/services/coins/banano/banano_wallet.dart +++ b/lib/services/coins/banano/banano_wallet.dart @@ -733,17 +733,29 @@ class BananoWallet extends CoinServiceAPI @override Future refresh() async { + if (refreshMutex) { + Logging.instance.log( + "$walletId $walletName refreshMutex denied", + level: LogLevel.Info, + ); + return; + } else { + refreshMutex = true; + } + await _prefs.init(); - GlobalEventBus.instance.fire( - WalletSyncStatusChangedEvent( - WalletSyncStatus.syncing, - walletId, - coin, - ), - ); - try { + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.syncing, + walletId, + coin, + ), + ); + + await _prefs.init(); + await updateChainHeight(); await updateTransactions(); await updateBalance(); @@ -768,6 +780,8 @@ class BananoWallet extends CoinServiceAPI ), ); } + + refreshMutex = false; } @override diff --git a/lib/services/coins/nano/nano_wallet.dart b/lib/services/coins/nano/nano_wallet.dart index 31114eef2..1f525d86d 100644 --- a/lib/services/coins/nano/nano_wallet.dart +++ b/lib/services/coins/nano/nano_wallet.dart @@ -747,17 +747,27 @@ class NanoWallet extends CoinServiceAPI @override Future refresh() async { - await _prefs.init(); - - GlobalEventBus.instance.fire( - WalletSyncStatusChangedEvent( - WalletSyncStatus.syncing, - walletId, - coin, - ), - ); + if (refreshMutex) { + Logging.instance.log( + "$walletId $walletName refreshMutex denied", + level: LogLevel.Info, + ); + return; + } else { + refreshMutex = true; + } try { + await _prefs.init(); + + GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.syncing, + walletId, + coin, + ), + ); + await updateChainHeight(); await updateTransactions(); await updateBalance(); @@ -782,6 +792,8 @@ class NanoWallet extends CoinServiceAPI ), ); } + + refreshMutex = false; } @override