mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-03 11:46:35 +00:00
optimize API calls
This commit is contained in:
parent
7ee9f33e5c
commit
8c30ff5adf
1 changed files with 14 additions and 10 deletions
|
@ -138,6 +138,15 @@ abstract class DashboardViewModelBase with Store {
|
|||
});
|
||||
|
||||
|
||||
reaction((_) => settingsStore.showHistoricalFiatAmount,
|
||||
(bool showHistoricalFiatAmount) {
|
||||
if (showHistoricalFiatAmount) {
|
||||
_wallet.transactionHistory.transactions.values.forEach((tx) {
|
||||
_getHistoricalFiatRate(tx);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (_wallet.type == WalletType.monero) {
|
||||
subname = monero!.getCurrentAccount(_wallet).label;
|
||||
|
||||
|
@ -182,14 +191,12 @@ abstract class DashboardViewModelBase with Store {
|
|||
settingsStore: appStore.settingsStore),
|
||||
filter: (TransactionInfo? transaction) {
|
||||
|
||||
_wallet.transactionHistory.transactions.values.forEach((tx) {
|
||||
_getHistoricalFiatRate(tx);
|
||||
});
|
||||
|
||||
if (transaction == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_getHistoricalFiatRate(transaction);
|
||||
|
||||
final wallet = _wallet;
|
||||
if (wallet.type == WalletType.monero) {
|
||||
return monero!.getTransactionInfoAccountId(transaction) == monero!.getCurrentAccount(wallet).id;
|
||||
|
@ -366,11 +373,6 @@ abstract class DashboardViewModelBase with Store {
|
|||
wallet.type == WalletType.bitcoin && wallet.seed.split(' ').length < 24;
|
||||
updateActions();
|
||||
|
||||
wallet.transactionHistory.transactions.values.forEach((tx) {
|
||||
_getHistoricalFiatRate(tx);
|
||||
});
|
||||
|
||||
|
||||
if (wallet.type == WalletType.monero) {
|
||||
subname = monero!.getCurrentAccount(wallet).label;
|
||||
|
||||
|
@ -448,9 +450,11 @@ abstract class DashboardViewModelBase with Store {
|
|||
}
|
||||
|
||||
Future<void> _getHistoricalFiatRate(TransactionInfo transactionInfo) async {
|
||||
if (FiatApiMode.disabled == settingsStore.fiatApiMode) return;
|
||||
if (FiatApiMode.disabled == settingsStore.fiatApiMode
|
||||
|| !settingsStore.showHistoricalFiatAmount) return;
|
||||
final description = getTransactionDescription(transactionInfo);
|
||||
|
||||
|
||||
if (description.historicalFiat != settingsStore.fiatCurrency.toString()
|
||||
|| description.historicalFiatRate == null) {
|
||||
if (description.key == 0) description.delete();
|
||||
|
|
Loading…
Reference in a new issue