From 94fd8bc0ec985133a0ef10ef90e1e9e29af1056b Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 19 Oct 2023 12:16:12 -0500 Subject: [PATCH] add flag to show try again button --- lib/models/fusion_progress_ui_state.dart | 11 +++++++++++ lib/services/mixins/fusion_wallet_interface.dart | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/models/fusion_progress_ui_state.dart b/lib/models/fusion_progress_ui_state.dart index 11aef7e6c..60217b2d6 100644 --- a/lib/models/fusion_progress_ui_state.dart +++ b/lib/models/fusion_progress_ui_state.dart @@ -109,6 +109,7 @@ class FusionProgressUIState extends ChangeNotifier { void incrementFusionRoundsCompleted() { _fusionRoundsCompleted++; _fusionRoundsFailed = 0; // Reset failed round count on success. + _maxConsecutiveFusionRoundsFailed = false; // Reset failed flag on success. notifyListeners(); } @@ -125,4 +126,14 @@ class FusionProgressUIState extends ChangeNotifier { _fusionRoundsFailed++; notifyListeners(); } + + /// A flag indicating that fusion has stopped because the maximum number of + /// consecutive failed fusion rounds has been reached. + bool _maxConsecutiveFusionRoundsFailed = false; + bool get maxConsecutiveFusionRoundsFailed => + _maxConsecutiveFusionRoundsFailed; + set maxConsecutiveFusionRoundsFailed(bool maxConsecutiveFusionRoundsFailed) { + _maxConsecutiveFusionRoundsFailed = maxConsecutiveFusionRoundsFailed; + notifyListeners(); + } } diff --git a/lib/services/mixins/fusion_wallet_interface.dart b/lib/services/mixins/fusion_wallet_interface.dart index fe47b3fe9..6bcb86817 100644 --- a/lib/services/mixins/fusion_wallet_interface.dart +++ b/lib/services/mixins/fusion_wallet_interface.dart @@ -569,9 +569,10 @@ mixin FusionWalletInterface { // Do the same for the UI state. _uiState?.incrementFusionRoundsFailed(); - // If we fail 5 times in a row, stop trying. + // If we fail too many times in a row, stop trying. if (_failedFuseCount >= maxFailedFuseCount) { _stopRequested = true; + _uiState?.maxConsecutiveFusionRoundsFailed = true; } } finally { // Increment the number of successfully completed fusion rounds.