1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 10:30:04 +01:00

fix double state update when account changed

This commit is contained in:
Esteban MIno 2018-07-30 20:36:31 -04:00
parent fbcba8f019
commit 822c1734d6

View File

@ -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
}
}