diff --git a/lib/wallet/bloc/state.dart b/lib/wallet/bloc/state.dart index 1f4bb018..5a5023b9 100644 --- a/lib/wallet/bloc/state.dart +++ b/lib/wallet/bloc/state.dart @@ -27,6 +27,7 @@ class WalletState with _$WalletState { @Default(0) int syncErrCount, // Address? newAddress, Address? firstAddress, + @Default(3) int loadingAttepmtsLeft, // required WalletCreate walletCreate, }) = _WalletState; const WalletState._(); diff --git a/lib/wallet/bloc/wallet_bloc.dart b/lib/wallet/bloc/wallet_bloc.dart index 821411fd..573a3105 100644 --- a/lib/wallet/bloc/wallet_bloc.dart +++ b/lib/wallet/bloc/wallet_bloc.dart @@ -136,8 +136,9 @@ class WalletBloc extends Bloc { Future _syncWallet(SyncWallet event, Emitter emit) async { if (state.wallet == null) return; if (state.syncing) return; - if (state.errLoadingWallet.isNotEmpty) { + if (state.errLoadingWallet.isNotEmpty && state.loadingAttepmtsLeft > 0) { add(LoadWallet(state.wallet!.getWalletStorageString())); + emit(state.copyWith(loadingAttepmtsLeft: state.loadingAttepmtsLeft - 1)); return; } // if (walletIsLoaded)