From 5787bac65857e03218e2150d0368a93548117aa2 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Fri, 20 Nov 2020 18:27:56 +0200 Subject: [PATCH] CAKE-158 | added _onMoneroBalanceChangeReaction instead _onMoneroTransactionsChangeReaction in the dashboard_view_model.dart --- lib/monero/monero_wallet.dart | 5 +++-- .../dashboard/dashboard_view_model.dart | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/monero/monero_wallet.dart b/lib/monero/monero_wallet.dart index a68dbffff..81a3ab7a6 100644 --- a/lib/monero/monero_wallet.dart +++ b/lib/monero/monero_wallet.dart @@ -367,17 +367,18 @@ abstract class MoneroWalletBase extends WalletBase with Store { void _onNewBlock(int height, int blocksLeft, double ptc) async { if (walletInfo.isRecovery) { - _askForUpdateTransactionHistory(); + await _askForUpdateTransactionHistory(); _askForUpdateBalance(); } if (blocksLeft < 100) { + await _askForUpdateTransactionHistory(); _askForUpdateBalance(); syncStatus = SyncedSyncStatus(); await _afterSyncSave(); if (walletInfo.isRecovery) { - setAsRecovered(); + await setAsRecovered(); } } else { syncStatus = SyncingSyncStatus(blocksLeft, ptc); diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index b95ebc680..1c632396a 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -2,7 +2,9 @@ import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart'; import 'package:cake_wallet/entities/transaction_history.dart'; import 'package:cake_wallet/monero/account.dart'; +import 'package:cake_wallet/monero/monero_balance.dart'; import 'package:cake_wallet/monero/monero_transaction_history.dart'; +import 'package:cake_wallet/monero/monero_transaction_info.dart'; import 'package:cake_wallet/monero/monero_wallet.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/crypto_currency.dart'; @@ -87,9 +89,9 @@ abstract class DashboardViewModelBase with Store { _onMoneroAccountChangeReaction = reaction((_) => _wallet.account, (Account account) => _onMoneroAccountChange(_wallet)); - _onMoneroTransactionsChangeReaction = reaction((_) => _wallet.transactionHistory, - (MoneroTransactionHistory transactionHistory) => - _onMoneroTransactionsUpdate(_wallet)); + _onMoneroBalanceChangeReaction = reaction((_) => + _wallet.balance, (MoneroBalance balance) => + _onMoneroTransactionsUpdate(_wallet)); final _accountTransactions = _wallet .transactionHistory.transactions.values @@ -193,7 +195,7 @@ abstract class DashboardViewModelBase with Store { ReactionDisposer _onMoneroAccountChangeReaction; - ReactionDisposer _onMoneroTransactionsChangeReaction; + ReactionDisposer _onMoneroBalanceChangeReaction; Future reconnect() async { final node = appStore.settingsStore.getCurrentNode(wallet.type); @@ -209,14 +211,14 @@ abstract class DashboardViewModelBase with Store { subname = wallet.account?.label; _onMoneroAccountChangeReaction?.reaction?.dispose(); - _onMoneroTransactionsChangeReaction?.reaction?.dispose(); + _onMoneroBalanceChangeReaction?.reaction?.dispose(); _onMoneroAccountChangeReaction = reaction((_) => wallet.account, (Account account) => _onMoneroAccountChange(wallet)); - _onMoneroTransactionsChangeReaction = reaction((_) => wallet.transactionHistory, - (MoneroTransactionHistory transactionHistory) => - _onMoneroTransactionsUpdate(wallet)); + _onMoneroBalanceChangeReaction = reaction((_) => + wallet.balance, (MoneroBalance balance) => + _onMoneroTransactionsUpdate(wallet)); _onMoneroTransactionsUpdate(wallet); } else {