fix: bottom sheet stuck on swap (#2211)

This commit is contained in:
Serhii 2025-04-17 06:14:12 +03:00 committed by GitHub
parent 77980496a8
commit b2d4698cdf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

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

View file

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