aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/selectors.js
diff options
context:
space:
mode:
authorDan J Miller <danjm.com@gmail.com>2019-01-30 20:16:12 +0800
committerWhymarrh Whitby <whymarrh.whitby@gmail.com>2019-01-30 20:16:12 +0800
commit02bdbbbc3e2d349ddde5657069ec6dda15fc6668 (patch)
tree09c2f2dad8263695dee5f49b0ae30c6b59503205 /ui/app/selectors.js
parentdf3169d1c7250d13bb8bc123dc91f7913ad75a81 (diff)
downloadtangerine-wallet-browser-02bdbbbc3e2d349ddde5657069ec6dda15fc6668.tar
tangerine-wallet-browser-02bdbbbc3e2d349ddde5657069ec6dda15fc6668.tar.gz
tangerine-wallet-browser-02bdbbbc3e2d349ddde5657069ec6dda15fc6668.tar.bz2
tangerine-wallet-browser-02bdbbbc3e2d349ddde5657069ec6dda15fc6668.tar.lz
tangerine-wallet-browser-02bdbbbc3e2d349ddde5657069ec6dda15fc6668.tar.xz
tangerine-wallet-browser-02bdbbbc3e2d349ddde5657069ec6dda15fc6668.tar.zst
tangerine-wallet-browser-02bdbbbc3e2d349ddde5657069ec6dda15fc6668.zip
Add visual indicator when displaying a cached balance (#5854)
Diffstat (limited to 'ui/app/selectors.js')
-rw-r--r--ui/app/selectors.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/ui/app/selectors.js b/ui/app/selectors.js
index f1ef41f28..c60b27ab4 100644
--- a/ui/app/selectors.js
+++ b/ui/app/selectors.js
@@ -37,6 +37,7 @@ const selectors = {
getMetaMaskAccounts,
getCurrentEthBalance,
getNetworkIdentifier,
+ isBalanceCached,
}
module.exports = selectors
@@ -62,7 +63,7 @@ function getSelectedIdentity (state) {
function getMetaMaskAccounts (state) {
const currentAccounts = state.metamask.accounts
- const cachedBalances = state.metamask.cachedBalances
+ const cachedBalances = state.metamask.cachedBalances[state.metamask.network]
const selectedAccounts = {}
Object.keys(currentAccounts).forEach(accountID => {
@@ -70,7 +71,7 @@ function getMetaMaskAccounts (state) {
if (account && account.balance === null || account.balance === undefined) {
selectedAccounts[accountID] = {
...account,
- balance: cachedBalances[accountID],
+ balance: cachedBalances && cachedBalances[accountID],
}
} else {
selectedAccounts[accountID] = account
@@ -79,6 +80,20 @@ function getMetaMaskAccounts (state) {
return selectedAccounts
}
+function isBalanceCached (state) {
+ const selectedAccountBalance = state.metamask.accounts[getSelectedAddress(state)].balance
+ const cachedBalance = getSelectedAccountCachedBalance(state)
+
+ return Boolean(!selectedAccountBalance && cachedBalance)
+}
+
+function getSelectedAccountCachedBalance (state) {
+ const cachedBalances = state.metamask.cachedBalances[state.metamask.network]
+ const selectedAddress = getSelectedAddress(state)
+
+ return cachedBalances && cachedBalances[selectedAddress]
+}
+
function getSelectedAccount (state) {
const accounts = getMetaMaskAccounts(state)
const selectedAddress = getSelectedAddress(state)