mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-09 12:29:31 +00:00
Cw 220 fix grey exchange screen (#641)
* Fix nullability issue for ChangeNow rateId * Handle concurrent modification error from Splay Tree
This commit is contained in:
parent
3d836d5dce
commit
bcf09b048c
1 changed files with 83 additions and 75 deletions
|
@ -7,7 +7,6 @@ import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart'
|
|||
import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart';
|
||||
import 'package:cake_wallet/exchange/simpleswap/simpleswap_exchange_provider.dart';
|
||||
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cake_wallet/exchange/simpleswap/simpleswap_request.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
|
@ -375,6 +374,7 @@ abstract class ExchangeViewModelBase with Store {
|
|||
TradeRequest? request;
|
||||
String amount = '';
|
||||
|
||||
try {
|
||||
for (var provider in _sortedAvailableProviders.values) {
|
||||
if (!(await provider.checkIsAvailable())) {
|
||||
continue;
|
||||
|
@ -465,6 +465,14 @@ abstract class ExchangeViewModelBase with Store {
|
|||
tradeState = TradeIsCreatedFailure(
|
||||
title: S.current.trade_not_created,
|
||||
error: S.current.none_of_selected_providers_can_exchange);
|
||||
} on ConcurrentModificationError {
|
||||
/// if create trade happened at the exact same time of the scheduled rate update
|
||||
/// then delay the create trade a bit and try again
|
||||
///
|
||||
/// this is because the limitation of the SplayTreeMap that
|
||||
/// you can't modify it while iterating through it
|
||||
Future.delayed(Duration(milliseconds: 500), createTrade);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
Loading…
Reference in a new issue