add flag to show try again button

This commit is contained in:
sneurlax 2023-10-19 12:16:12 -05:00
parent e88676cf40
commit 94fd8bc0ec
2 changed files with 13 additions and 1 deletions

View file

@ -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();
}
}

View file

@ -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.