Skip to content

Commit

Permalink
Update tokens after importing account
Browse files Browse the repository at this point in the history
Tokens are now updated when the account switches after a failed account
import. The usual account switching flow (via the account menu) already
updated tokens, but this step was omitted when the account switched
after a failed import.
  • Loading branch information
Gudahtt committed May 1, 2020
1 parent 165666b commit 502d1f4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ui/app/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1159,12 +1159,18 @@ export function setSelectedToken (tokenAddress) {
}
}

async function _setSelectedAddress (dispatch, address) {
log.debug(`background.setSelectedAddress`)
const tokens = await promisifiedBackground.setSelectedAddress(address)
dispatch(updateTokens(tokens))
}

export function setSelectedAddress (address) {
return async (dispatch) => {
dispatch(showLoadingIndication())
log.debug(`background.setSelectedAddress`)
try {
await promisifiedBackground.setSelectedAddress(address)
await _setSelectedAddress(dispatch, address)
} catch (error) {
dispatch(hideLoadingIndication())
dispatch(displayWarning(error.message))
Expand All @@ -1186,16 +1192,14 @@ export function showAccountDetail (address) {
const currentTabIsConnectedToNextAddress = permittedAccountsForCurrentTab.includes(address)
const switchingToUnconnectedAddress = currentTabIsConnectedToPreviousAddress && !currentTabIsConnectedToNextAddress

let tokens
try {
tokens = await promisifiedBackground.setSelectedAddress(address)
await _setSelectedAddress(dispatch, address)
} catch (error) {
dispatch(hideLoadingIndication())
dispatch(displayWarning(error.message))
return
}
dispatch(hideLoadingIndication())
dispatch(updateTokens(tokens))
dispatch({
type: actionConstants.SHOW_ACCOUNT_DETAIL,
value: address,
Expand Down

0 comments on commit 502d1f4

Please sign in to comment.