mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
CAKE-158 | added calculating balance to _onAccountChangeReaction in the monero wallet; created _onMoneroAccountChange method in the dashboard_view_model.dart; added _onMoneroAccountChangeReaction and account filter to transaction list in the dashboard_view_model.dart
This commit is contained in:
parent
58280d1bb2
commit
f704bdc864
2 changed files with 69 additions and 20 deletions
|
@ -40,6 +40,10 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||||
fullBalance: monero_wallet.getFullBalance(accountIndex: 0),
|
fullBalance: monero_wallet.getFullBalance(accountIndex: 0),
|
||||||
unlockedBalance: monero_wallet.getFullBalance(accountIndex: 0));
|
unlockedBalance: monero_wallet.getFullBalance(accountIndex: 0));
|
||||||
_onAccountChangeReaction = reaction((_) => account, (Account account) {
|
_onAccountChangeReaction = reaction((_) => account, (Account account) {
|
||||||
|
balance = MoneroBalance(
|
||||||
|
fullBalance: monero_wallet.getFullBalance(accountIndex: account.id),
|
||||||
|
unlockedBalance:
|
||||||
|
monero_wallet.getUnlockedBalance(accountIndex: account.id));
|
||||||
subaddressList.update(accountIndex: account.id);
|
subaddressList.update(accountIndex: account.id);
|
||||||
subaddress = subaddressList.subaddresses.first;
|
subaddress = subaddressList.subaddresses.first;
|
||||||
address = subaddress.address;
|
address = subaddress.address;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
|
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/monero/account.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';
|
||||||
|
@ -74,6 +75,26 @@ abstract class DashboardViewModelBase with Store {
|
||||||
wallet ??= appStore.wallet;
|
wallet ??= appStore.wallet;
|
||||||
type = wallet.type;
|
type = wallet.type;
|
||||||
|
|
||||||
|
_reaction = reaction((_) => appStore.wallet, _onWalletChange);
|
||||||
|
|
||||||
|
final _wallet = wallet;
|
||||||
|
|
||||||
|
if (_wallet is MoneroWallet) {
|
||||||
|
subname = _wallet.account?.label;
|
||||||
|
|
||||||
|
_onMoneroAccountChangeReaction = reaction((_) => _wallet.account,
|
||||||
|
(Account account) => _onMoneroAccountChange(_wallet));
|
||||||
|
|
||||||
|
final _accountTransactions = _wallet
|
||||||
|
.transactionHistory.transactions.values
|
||||||
|
.where((tx) => tx.accountIndex == _wallet.account.id).toList();
|
||||||
|
|
||||||
|
transactions = ObservableList.of(_accountTransactions
|
||||||
|
.map((transaction) => TransactionListItem(
|
||||||
|
transaction: transaction,
|
||||||
|
balanceViewModel: balanceViewModel,
|
||||||
|
settingsStore: appStore.settingsStore)));
|
||||||
|
} else {
|
||||||
transactions = ObservableList.of(wallet
|
transactions = ObservableList.of(wallet
|
||||||
.transactionHistory.transactions.values
|
.transactionHistory.transactions.values
|
||||||
.map((transaction) => TransactionListItem(
|
.map((transaction) => TransactionListItem(
|
||||||
|
@ -81,7 +102,6 @@ abstract class DashboardViewModelBase with Store {
|
||||||
balanceViewModel: balanceViewModel,
|
balanceViewModel: balanceViewModel,
|
||||||
settingsStore: appStore.settingsStore)));
|
settingsStore: appStore.settingsStore)));
|
||||||
|
|
||||||
_reaction = reaction((_) => appStore.wallet, _onWalletChange);
|
|
||||||
// FIXME: fixme
|
// FIXME: fixme
|
||||||
connectMapToListWithTransform(
|
connectMapToListWithTransform(
|
||||||
appStore.wallet.transactionHistory.transactions,
|
appStore.wallet.transactionHistory.transactions,
|
||||||
|
@ -90,11 +110,6 @@ abstract class DashboardViewModelBase with Store {
|
||||||
transaction: val,
|
transaction: val,
|
||||||
balanceViewModel: balanceViewModel,
|
balanceViewModel: balanceViewModel,
|
||||||
settingsStore: appStore.settingsStore));
|
settingsStore: appStore.settingsStore));
|
||||||
|
|
||||||
final _wallet = wallet;
|
|
||||||
|
|
||||||
if (_wallet is MoneroWallet) {
|
|
||||||
subname = _wallet.account?.label;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +185,8 @@ abstract class DashboardViewModelBase with Store {
|
||||||
|
|
||||||
ReactionDisposer _reaction;
|
ReactionDisposer _reaction;
|
||||||
|
|
||||||
|
ReactionDisposer _onMoneroAccountChangeReaction;
|
||||||
|
|
||||||
Future<void> reconnect() async {
|
Future<void> reconnect() async {
|
||||||
final node = appStore.settingsStore.getCurrentNode(wallet.type);
|
final node = appStore.settingsStore.getCurrentNode(wallet.type);
|
||||||
await wallet.connectToNode(node: node);
|
await wallet.connectToNode(node: node);
|
||||||
|
@ -180,10 +197,38 @@ abstract class DashboardViewModelBase with Store {
|
||||||
this.wallet = wallet;
|
this.wallet = wallet;
|
||||||
name = wallet.name;
|
name = wallet.name;
|
||||||
transactions.clear();
|
transactions.clear();
|
||||||
|
|
||||||
|
if (wallet is MoneroWallet) {
|
||||||
|
final _accountTransactions = wallet
|
||||||
|
.transactionHistory.transactions.values
|
||||||
|
.where((tx) => tx.accountIndex == wallet.account.id).toList();
|
||||||
|
|
||||||
|
transactions.addAll(_accountTransactions
|
||||||
|
.map((transaction) => TransactionListItem(
|
||||||
|
transaction: transaction,
|
||||||
|
balanceViewModel: balanceViewModel,
|
||||||
|
settingsStore: appStore.settingsStore)));
|
||||||
|
} else {
|
||||||
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)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
void _onMoneroAccountChange(MoneroWallet wallet) {
|
||||||
|
transactions.clear();
|
||||||
|
|
||||||
|
final _accountTransactions = wallet
|
||||||
|
.transactionHistory.transactions.values
|
||||||
|
.where((tx) => tx.accountIndex == wallet.account.id).toList();
|
||||||
|
|
||||||
|
transactions.addAll(_accountTransactions
|
||||||
|
.map((transaction) => TransactionListItem(
|
||||||
|
transaction: transaction,
|
||||||
|
balanceViewModel: balanceViewModel,
|
||||||
|
settingsStore: appStore.settingsStore)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue