From 822c1734d6e3cb9a60306c1b89617c1013627f57 Mon Sep 17 00:00:00 2001 From: Esteban MIno Date: Mon, 30 Jul 2018 20:36:31 -0400 Subject: [PATCH] fix double state update when account changed --- app/scripts/controllers/preferences.js | 8 +++----- 1 file 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 } }