CW-395-Trade-ID-status-not-updating-in-trade-details-screen (#957)

* fix ChangeNow trade status

* formatting

* fix hive saving

* Revert SideShift changes

This reverts commit
This commit is contained in:
Serhii 2023-06-14 23:55:49 +03:00 committed by GitHub
parent f88e150cd1
commit f1904077d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View file

@ -192,11 +192,11 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
final expectedSendAmount = responseJSON['expectedAmountFrom'].toString();
final status = responseJSON['status'] as String;
final state = TradeState.deserialize(raw: status);
final extraId = responseJSON['payinExtraId'] as String;
final outputTransaction = responseJSON['payoutHash'] as String;
final expiredAtRaw = responseJSON['validUntil'] as String;
final extraId = responseJSON['payinExtraId'] as String?;
final outputTransaction = responseJSON['payoutHash'] as String?;
final expiredAtRaw = responseJSON['validUntil'] as String?;
final payoutAddress = responseJSON['payoutAddress'] as String;
final expiredAt = DateTime.tryParse(expiredAtRaw)?.toLocal();
final expiredAt = DateTime.tryParse(expiredAtRaw ?? '')?.toLocal();
return Trade(
id: id,

View file

@ -21,6 +21,7 @@ import 'package:cake_wallet/src/screens/trade_details/track_trade_list_item.dart
import 'package:cake_wallet/src/screens/trade_details/trade_details_list_card.dart';
import 'package:cake_wallet/src/screens/trade_details/trade_details_status_item.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:collection/collection.dart';
part 'trade_details_view_model.g.dart';
@ -32,7 +33,8 @@ abstract class TradeDetailsViewModelBase with Store {
required this.trades,
required this.settingsStore,
}) : items = ObservableList<StandartListItem>(),
trade = tradeForDetails {
trade = trades.values.firstWhereOrNull((element) => element.id == tradeForDetails.id) ??
tradeForDetails {
switch (trade.provider) {
case ExchangeProviderDescription.xmrto:
_provider = XMRTOExchangeProvider();
@ -54,8 +56,6 @@ abstract class TradeDetailsViewModelBase with Store {
break;
}
items = ObservableList<StandartListItem>();
_updateItems();
_updateTrade();
@ -85,6 +85,12 @@ abstract class TradeDetailsViewModelBase with Store {
if (updatedTrade.createdAt == null && trade.createdAt != null) {
updatedTrade.createdAt = trade.createdAt;
}
Trade? foundElement = trades.values.firstWhereOrNull((element) => element.id == trade.id);
if (foundElement != null) {
final editedTrade = trades.get(foundElement.key);
editedTrade?.stateRaw = updatedTrade.stateRaw;
editedTrade?.save();
}
trade = updatedTrade;
@ -154,8 +160,9 @@ abstract class TradeDetailsViewModelBase with Store {
}
void _launchUrl(String url) {
final uri = Uri.parse(url);
try {
launch(url);
launchUrl(uri);
} catch (e) {}
}
}