CAKE-158 | added _onMoneroBalanceChangeReaction instead _onMoneroTransactionsChangeReaction in the dashboard_view_model.dart

This commit is contained in:
OleksandrSobol 2020-11-20 18:27:56 +02:00
parent 7aecb33044
commit 5787bac658
2 changed files with 13 additions and 10 deletions

View file

@ -367,17 +367,18 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
void _onNewBlock(int height, int blocksLeft, double ptc) async { void _onNewBlock(int height, int blocksLeft, double ptc) async {
if (walletInfo.isRecovery) { if (walletInfo.isRecovery) {
_askForUpdateTransactionHistory(); await _askForUpdateTransactionHistory();
_askForUpdateBalance(); _askForUpdateBalance();
} }
if (blocksLeft < 100) { if (blocksLeft < 100) {
await _askForUpdateTransactionHistory();
_askForUpdateBalance(); _askForUpdateBalance();
syncStatus = SyncedSyncStatus(); syncStatus = SyncedSyncStatus();
await _afterSyncSave(); await _afterSyncSave();
if (walletInfo.isRecovery) { if (walletInfo.isRecovery) {
setAsRecovered(); await setAsRecovered();
} }
} else { } else {
syncStatus = SyncingSyncStatus(blocksLeft, ptc); syncStatus = SyncingSyncStatus(blocksLeft, ptc);

View file

@ -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/bitcoin/bitcoin_wallet.dart';
import 'package:cake_wallet/entities/transaction_history.dart'; import 'package:cake_wallet/entities/transaction_history.dart';
import 'package:cake_wallet/monero/account.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_history.dart';
import 'package:cake_wallet/monero/monero_transaction_info.dart';
import 'package:cake_wallet/monero/monero_wallet.dart'; import 'package:cake_wallet/monero/monero_wallet.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/entities/crypto_currency.dart';
@ -87,9 +89,9 @@ abstract class DashboardViewModelBase with Store {
_onMoneroAccountChangeReaction = reaction((_) => _wallet.account, _onMoneroAccountChangeReaction = reaction((_) => _wallet.account,
(Account account) => _onMoneroAccountChange(_wallet)); (Account account) => _onMoneroAccountChange(_wallet));
_onMoneroTransactionsChangeReaction = reaction((_) => _wallet.transactionHistory, _onMoneroBalanceChangeReaction = reaction((_) =>
(MoneroTransactionHistory transactionHistory) => _wallet.balance, (MoneroBalance balance) =>
_onMoneroTransactionsUpdate(_wallet)); _onMoneroTransactionsUpdate(_wallet));
final _accountTransactions = _wallet final _accountTransactions = _wallet
.transactionHistory.transactions.values .transactionHistory.transactions.values
@ -193,7 +195,7 @@ abstract class DashboardViewModelBase with Store {
ReactionDisposer _onMoneroAccountChangeReaction; ReactionDisposer _onMoneroAccountChangeReaction;
ReactionDisposer _onMoneroTransactionsChangeReaction; ReactionDisposer _onMoneroBalanceChangeReaction;
Future<void> reconnect() async { Future<void> reconnect() async {
final node = appStore.settingsStore.getCurrentNode(wallet.type); final node = appStore.settingsStore.getCurrentNode(wallet.type);
@ -209,14 +211,14 @@ abstract class DashboardViewModelBase with Store {
subname = wallet.account?.label; subname = wallet.account?.label;
_onMoneroAccountChangeReaction?.reaction?.dispose(); _onMoneroAccountChangeReaction?.reaction?.dispose();
_onMoneroTransactionsChangeReaction?.reaction?.dispose(); _onMoneroBalanceChangeReaction?.reaction?.dispose();
_onMoneroAccountChangeReaction = reaction((_) => wallet.account, _onMoneroAccountChangeReaction = reaction((_) => wallet.account,
(Account account) => _onMoneroAccountChange(wallet)); (Account account) => _onMoneroAccountChange(wallet));
_onMoneroTransactionsChangeReaction = reaction((_) => wallet.transactionHistory, _onMoneroBalanceChangeReaction = reaction((_) =>
(MoneroTransactionHistory transactionHistory) => wallet.balance, (MoneroBalance balance) =>
_onMoneroTransactionsUpdate(wallet)); _onMoneroTransactionsUpdate(wallet));
_onMoneroTransactionsUpdate(wallet); _onMoneroTransactionsUpdate(wallet);
} else { } else {