diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 40a07e666..575193027 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -258,33 +258,34 @@ abstract class DashboardViewModelBase with Store { _checkMweb(); }); - connectMapToListWithTransform( - appStore.wallet!.transactionHistory.transactions, - transactions, - (TransactionInfo? transaction) => TransactionListItem( - transaction: transaction!, - balanceViewModel: balanceViewModel, - settingsStore: appStore.settingsStore, - key: ValueKey( - '${_wallet.type.name}_transaction_history_item_${transaction.id}_key', + _transactionDisposer?.reaction.dispose(); + + _transactionDisposer = reaction( + (_) => appStore.wallet!.transactionHistory.transactions.values.toList(), + (List txs) { + + transactions.clear(); + + transactions.addAll( + txs.where((tx) { + if (wallet.type == WalletType.monero) { + return monero!.getTransactionInfoAccountId(tx) == monero!.getCurrentAccount(wallet).id; + } + if (wallet.type == WalletType.wownero) { + return wow.wownero!.getTransactionInfoAccountId(tx) == wow.wownero!.getCurrentAccount(wallet).id; + } + return true; + }).map( + (tx) => TransactionListItem( + transaction: tx, + balanceViewModel: balanceViewModel, + settingsStore: appStore.settingsStore, + key: ValueKey('${wallet.type.name}_transaction_history_item_${tx.id}_key'), ), - ), filter: (TransactionInfo? transaction) { - if (transaction == null) { - return false; - } - - final wallet = _wallet; - if (wallet.type == WalletType.monero) { - return monero!.getTransactionInfoAccountId(transaction) == - monero!.getCurrentAccount(wallet).id; - } - if (wallet.type == WalletType.wownero) { - return wow.wownero!.getTransactionInfoAccountId(transaction) == - wow.wownero!.getCurrentAccount(wallet).id; - } - - return true; - }); + ), + ); + } + ); if (hasSilentPayments) { silentPaymentsScanningActive = bitcoin!.getScanningActive(wallet); @@ -583,6 +584,8 @@ abstract class DashboardViewModelBase with Store { ReactionDisposer? _onMoneroBalanceChangeReaction; + ReactionDisposer? _transactionDisposer; + @computed bool get hasPowNodes => [WalletType.nano, WalletType.banano].contains(wallet.type); @@ -687,32 +690,34 @@ abstract class DashboardViewModelBase with Store { ); } - connectMapToListWithTransform( - appStore.wallet!.transactionHistory.transactions, - transactions, - (TransactionInfo? transaction) => TransactionListItem( - transaction: transaction!, - balanceViewModel: balanceViewModel, - settingsStore: appStore.settingsStore, - key: ValueKey( - '${wallet.type.name}_transaction_history_item_${transaction.id}_key', + _transactionDisposer?.reaction.dispose(); + + _transactionDisposer = reaction( + (_) => appStore.wallet!.transactionHistory.transactions.values.toList(), + (List txs) { + + transactions.clear(); + + transactions.addAll( + txs.where((tx) { + if (wallet.type == WalletType.monero) { + return monero!.getTransactionInfoAccountId(tx) == monero!.getCurrentAccount(wallet).id; + } + if (wallet.type == WalletType.wownero) { + return wow.wownero!.getTransactionInfoAccountId(tx) == wow.wownero!.getCurrentAccount(wallet).id; + } + return true; + }).map( + (tx) => TransactionListItem( + transaction: tx, + balanceViewModel: balanceViewModel, + settingsStore: appStore.settingsStore, + key: ValueKey('${wallet.type.name}_transaction_history_item_${tx.id}_key'), ), - ), filter: (TransactionInfo? tx) { - if (tx == null) { - return false; - } - - if (wallet.type == WalletType.monero) { - return monero!.getTransactionInfoAccountId(tx) == monero!.getCurrentAccount(wallet).id; - } - - if (wallet.type == WalletType.wownero) { - return wow.wownero!.getTransactionInfoAccountId(tx) == - wow.wownero!.getCurrentAccount(wallet).id; - } - - return true; - }); + ), + ); + } + ); } @action