refactor logic to fail currently-running state step

This commit is contained in:
sneurlax 2023-10-13 13:29:04 -05:00
parent c61f3ca94b
commit ad965e081c

View file

@ -112,10 +112,14 @@ mixin FusionWalletInterface {
case fusion.FusionStatus.failed:
_uiState?.fusing = CashFusionStatus.failed;
_uiState?.complete = CashFusionStatus.failed;
failCurrentUiState();
break;
case fusion.FusionStatus.exception:
_uiState?.fusing = CashFusionStatus.failed;
_uiState?.complete = CashFusionStatus.failed;
failCurrentUiState();
break;
case fusion.FusionStatus.reset:
_uiState?.outputs = CashFusionStatus.waiting;
@ -128,6 +132,22 @@ mixin FusionWalletInterface {
}
}
void failCurrentUiState() {
// Check each _uiState value to see if it is running. If so, set it to failed.
if (_uiState?.connecting == CashFusionStatus.running) {
_uiState?.connecting = CashFusionStatus.failed;
}
if (_uiState?.outputs == CashFusionStatus.running) {
_uiState?.outputs = CashFusionStatus.failed;
}
if (_uiState?.peers == CashFusionStatus.running) {
_uiState?.peers = CashFusionStatus.failed;
}
if (_uiState?.fusing == CashFusionStatus.running) {
_uiState?.fusing = CashFusionStatus.failed;
}
}
/// Returns a list of all transactions in the wallet for the given address.
Future<List<Map<String, dynamic>>> _getTransactionsByAddress(
String address,