mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 20:09:24 +00:00
Changed listener for update of transactions list.
This commit is contained in:
parent
042b17a82f
commit
cbf265bd92
1 changed files with 40 additions and 34 deletions
|
@ -87,38 +87,45 @@ abstract class DashboardViewModelBase with Store {
|
||||||
subname = _wallet.account?.label;
|
subname = _wallet.account?.label;
|
||||||
|
|
||||||
_onMoneroAccountChangeReaction = reaction((_) => _wallet.account,
|
_onMoneroAccountChangeReaction = reaction((_) => _wallet.account,
|
||||||
(Account account) => _onMoneroAccountChange(_wallet));
|
(Account account) => _onMoneroAccountChange(_wallet));
|
||||||
|
|
||||||
_onMoneroBalanceChangeReaction = reaction((_) =>
|
_onMoneroBalanceChangeReaction = reaction((_) => _wallet.balance,
|
||||||
_wallet.balance, (MoneroBalance balance) =>
|
(MoneroBalance balance) => _onMoneroTransactionsUpdate(_wallet));
|
||||||
_onMoneroTransactionsUpdate(_wallet));
|
|
||||||
|
|
||||||
final _accountTransactions = _wallet
|
final _accountTransactions = _wallet
|
||||||
.transactionHistory.transactions.values
|
.transactionHistory.transactions.values
|
||||||
.where((tx) => tx.accountIndex == _wallet.account.id).toList();
|
.where((tx) => tx.accountIndex == _wallet.account.id)
|
||||||
|
.toList();
|
||||||
|
|
||||||
transactions = ObservableList.of(_accountTransactions
|
transactions = ObservableList.of(_accountTransactions.map((transaction) =>
|
||||||
.map((transaction) => TransactionListItem(
|
TransactionListItem(
|
||||||
transaction: transaction,
|
transaction: transaction,
|
||||||
balanceViewModel: balanceViewModel,
|
balanceViewModel: balanceViewModel,
|
||||||
settingsStore: appStore.settingsStore)));
|
settingsStore: appStore.settingsStore)));
|
||||||
} else {
|
} else {
|
||||||
transactions = ObservableList.of(wallet
|
transactions = ObservableList.of(wallet
|
||||||
.transactionHistory.transactions.values
|
.transactionHistory.transactions.values
|
||||||
.map((transaction) => TransactionListItem(
|
.map((transaction) => TransactionListItem(
|
||||||
transaction: transaction,
|
transaction: transaction,
|
||||||
balanceViewModel: balanceViewModel,
|
|
||||||
settingsStore: appStore.settingsStore)));
|
|
||||||
|
|
||||||
// FIXME: fixme
|
|
||||||
connectMapToListWithTransform(
|
|
||||||
appStore.wallet.transactionHistory.transactions,
|
|
||||||
transactions,
|
|
||||||
(TransactionInfo val) => TransactionListItem(
|
|
||||||
transaction: val,
|
|
||||||
balanceViewModel: balanceViewModel,
|
balanceViewModel: balanceViewModel,
|
||||||
settingsStore: appStore.settingsStore));
|
settingsStore: appStore.settingsStore)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectMapToListWithTransform(
|
||||||
|
appStore.wallet.transactionHistory.transactions,
|
||||||
|
transactions,
|
||||||
|
(TransactionInfo val) => TransactionListItem(
|
||||||
|
transaction: val,
|
||||||
|
balanceViewModel: balanceViewModel,
|
||||||
|
settingsStore: appStore.settingsStore),
|
||||||
|
filter: (TransactionInfo tx) {
|
||||||
|
final wallet = _wallet;
|
||||||
|
if (tx is MoneroTransactionInfo && wallet is MoneroWallet) {
|
||||||
|
return tx.accountIndex == wallet.account.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
|
@ -214,18 +221,17 @@ abstract class DashboardViewModelBase with Store {
|
||||||
_onMoneroBalanceChangeReaction?.reaction?.dispose();
|
_onMoneroBalanceChangeReaction?.reaction?.dispose();
|
||||||
|
|
||||||
_onMoneroAccountChangeReaction = reaction((_) => wallet.account,
|
_onMoneroAccountChangeReaction = reaction((_) => wallet.account,
|
||||||
(Account account) => _onMoneroAccountChange(wallet));
|
(Account account) => _onMoneroAccountChange(wallet));
|
||||||
|
|
||||||
_onMoneroBalanceChangeReaction = reaction((_) =>
|
_onMoneroBalanceChangeReaction = reaction((_) => wallet.balance,
|
||||||
wallet.balance, (MoneroBalance balance) =>
|
(MoneroBalance balance) => _onMoneroTransactionsUpdate(wallet));
|
||||||
_onMoneroTransactionsUpdate(wallet));
|
|
||||||
|
|
||||||
_onMoneroTransactionsUpdate(wallet);
|
_onMoneroTransactionsUpdate(wallet);
|
||||||
} else {
|
} else {
|
||||||
transactions.clear();
|
transactions.clear();
|
||||||
|
|
||||||
transactions.addAll(wallet.transactionHistory.transactions.values.map(
|
transactions.addAll(wallet.transactionHistory.transactions.values.map(
|
||||||
(transaction) => TransactionListItem(
|
(transaction) => TransactionListItem(
|
||||||
transaction: transaction,
|
transaction: transaction,
|
||||||
balanceViewModel: balanceViewModel,
|
balanceViewModel: balanceViewModel,
|
||||||
settingsStore: appStore.settingsStore)));
|
settingsStore: appStore.settingsStore)));
|
||||||
|
@ -242,14 +248,14 @@ abstract class DashboardViewModelBase with Store {
|
||||||
void _onMoneroTransactionsUpdate(MoneroWallet wallet) {
|
void _onMoneroTransactionsUpdate(MoneroWallet wallet) {
|
||||||
transactions.clear();
|
transactions.clear();
|
||||||
|
|
||||||
final _accountTransactions = wallet
|
final _accountTransactions = wallet.transactionHistory.transactions.values
|
||||||
.transactionHistory.transactions.values
|
.where((tx) => tx.accountIndex == wallet.account.id)
|
||||||
.where((tx) => tx.accountIndex == wallet.account.id).toList();
|
.toList();
|
||||||
|
|
||||||
transactions.addAll(_accountTransactions
|
transactions.addAll(_accountTransactions.map((transaction) =>
|
||||||
.map((transaction) => TransactionListItem(
|
TransactionListItem(
|
||||||
transaction: transaction,
|
transaction: transaction,
|
||||||
balanceViewModel: balanceViewModel,
|
balanceViewModel: balanceViewModel,
|
||||||
settingsStore: appStore.settingsStore)));
|
settingsStore: appStore.settingsStore)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue