aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban MIno <efmino@uc.cl>2018-07-31 08:36:31 +0800
committerEsteban MIno <efmino@uc.cl>2018-07-31 08:36:31 +0800
commit822c1734d6e3cb9a60306c1b89617c1013627f57 (patch)
treecfb171c0d9684f702b2d9f3019fc5b5ef66e9973
parentfbcba8f019313c3b02429043578e044046c6cc68 (diff)
downloadtangerine-wallet-browser-822c1734d6e3cb9a60306c1b89617c1013627f57.tar.gz
tangerine-wallet-browser-822c1734d6e3cb9a60306c1b89617c1013627f57.tar.zst
tangerine-wallet-browser-822c1734d6e3cb9a60306c1b89617c1013627f57.zip
fix double state update when account changed
-rw-r--r--app/scripts/controllers/preferences.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index 5c158288b..193965c2c 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -195,8 +195,8 @@ class PreferencesController {
*/
setSelectedAddress (_address) {
const address = normalizeAddress(_address)
- this.store.updateState({ selectedAddress: address })
- const tokens = this._updateTokens()
+ const tokens = this._updateTokens(address)
+ this.store.updateState({ selectedAddress: address, tokens })
return Promise.resolve(tokens)
}
@@ -421,14 +421,12 @@ class PreferencesController {
*
*
*/
- _updateTokens () {
+ _updateTokens (selectedAddress) {
const accountTokens = this.store.getState().accountTokens
- const selectedAddress = this.store.getState().selectedAddress
const providerType = this.network.providerStore.getState().type
if (!(selectedAddress in accountTokens)) accountTokens[selectedAddress] = {}
if (!(providerType in accountTokens[selectedAddress])) accountTokens[selectedAddress][providerType] = []
const tokens = accountTokens[selectedAddress][providerType]
- this.store.updateState({ tokens })
return tokens
}
}