From 7c15b2dd9ab82dc3f8dee404edc340e2ca67a8df Mon Sep 17 00:00:00 2001 From: mocodesmo Date: Sat, 28 Dec 2024 03:35:11 +0530 Subject: [PATCH] WALLET - reloading wallet - max attempts conditions --- lib/wallet/bloc/state.dart | 1 + lib/wallet/bloc/wallet_bloc.dart | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) 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)