mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
fix: bottom sheet stuck on swap (#2211)
This commit is contained in:
@@ -7,6 +7,7 @@ class TradeState extends EnumerableItem<String> with Serializable<String> {
|
||||
bool operator ==(Object other) => other is TradeState && other.raw == raw;
|
||||
|
||||
static const pending = TradeState(raw: 'pending', title: 'Pending');
|
||||
static const awaiting = TradeState(raw: 'awaiting', title: 'Awaiting');
|
||||
static const confirming = TradeState(raw: 'confirming', title: 'Confirming');
|
||||
static const trading = TradeState(raw: 'trading', title: 'Trading');
|
||||
static const traded = TradeState(raw: 'traded', title: 'Traded');
|
||||
@@ -134,6 +135,8 @@ class TradeState extends EnumerableItem<String> with Serializable<String> {
|
||||
return success;
|
||||
case 'expired':
|
||||
return expired;
|
||||
case 'awaiting':
|
||||
return awaiting;
|
||||
default:
|
||||
throw Exception('Unexpected token: $raw in TradeState deserialize');
|
||||
}
|
||||
|
||||
@@ -205,6 +205,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||
);
|
||||
}
|
||||
|
||||
BuildContext? dialogContext;
|
||||
BuildContext? loadingBottomSheetContext;
|
||||
|
||||
void _setEffects() {
|
||||
@@ -213,7 +214,12 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||
}
|
||||
|
||||
_exchangeStateReaction = reaction((_) => this.widget.exchangeTradeViewModel.sendViewModel.state,
|
||||
(ExecutionState state) {
|
||||
(ExecutionState state) async {
|
||||
|
||||
if (dialogContext != null && dialogContext?.mounted == true) {
|
||||
Navigator.of(dialogContext!).pop();
|
||||
}
|
||||
|
||||
if (state is! IsExecutingState &&
|
||||
loadingBottomSheetContext != null &&
|
||||
loadingBottomSheetContext!.mounted) {
|
||||
@@ -237,6 +243,13 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||
}
|
||||
|
||||
if (state is IsExecutingState) {
|
||||
// wait a bit to avoid showing the loading dialog if transaction is failed
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
final currentState = widget.exchangeTradeViewModel.sendViewModel.state;
|
||||
if (currentState is ExecutedSuccessfullyState || currentState is FailureState) {
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (context.mounted) {
|
||||
showModalBottomSheet<void>(
|
||||
|
||||
Reference in New Issue
Block a user