From 993dea82a929d14a141287aeb41ec44042ee10a6 Mon Sep 17 00:00:00 2001 From: Serhii Date: Thu, 20 Feb 2025 18:53:18 +0200 Subject: [PATCH 1/3] replace connectMapToListWithTransform with reaction --- .../dashboard/dashboard_view_model.dart | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 99283a409..7cc26b33e 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -578,6 +578,8 @@ abstract class DashboardViewModelBase with Store { ReactionDisposer? _onMoneroBalanceChangeReaction; + ReactionDisposer? _transactionDisposer; + @computed bool get hasPowNodes => [WalletType.nano, WalletType.banano].contains(wallet.type); @@ -682,32 +684,35 @@ 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) { + // Clear existing transactions + transactions.clear(); + + // Apply filtering before adding to the list + 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; // Include other wallet types without filtering + }).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 From 068d6916b977b0500a06fc4577113764a38f8377 Mon Sep 17 00:00:00 2001 From: Serhii Date: Thu, 20 Feb 2025 19:19:01 +0200 Subject: [PATCH 2/3] minor fixes --- lib/view_model/dashboard/dashboard_view_model.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 7cc26b33e..2834be0e1 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -689,10 +689,9 @@ abstract class DashboardViewModelBase with Store { _transactionDisposer = reaction( (_) => appStore.wallet!.transactionHistory.transactions.values.toList(), (List txs) { - // Clear existing transactions - transactions.clear(); - // Apply filtering before adding to the list + transactions.clear(); + transactions.addAll( txs.where((tx) { if (wallet.type == WalletType.monero) { @@ -701,7 +700,7 @@ abstract class DashboardViewModelBase with Store { if (wallet.type == WalletType.wownero) { return wow.wownero!.getTransactionInfoAccountId(tx) == wow.wownero!.getCurrentAccount(wallet).id; } - return true; // Include other wallet types without filtering + return true; }).map( (tx) => TransactionListItem( transaction: tx, From 8009ee061c02c71e09d7e8a90b30bbd849e73eb4 Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 7 Mar 2025 14:48:36 +0200 Subject: [PATCH 3/3] Update dashboard_view_model.dart --- .../dashboard/dashboard_view_model.dart | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 2834be0e1..d070b2ff9 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -253,33 +253,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);