mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Update tokens after importing account (#8491)
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.
This commit is contained in:
parent
5b5b67a985
commit
902ed3d649
@ -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) {
|
export function setSelectedAddress (address) {
|
||||||
return async (dispatch) => {
|
return async (dispatch) => {
|
||||||
dispatch(showLoadingIndication())
|
dispatch(showLoadingIndication())
|
||||||
log.debug(`background.setSelectedAddress`)
|
log.debug(`background.setSelectedAddress`)
|
||||||
try {
|
try {
|
||||||
await promisifiedBackground.setSelectedAddress(address)
|
await _setSelectedAddress(dispatch, address)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(hideLoadingIndication())
|
dispatch(hideLoadingIndication())
|
||||||
dispatch(displayWarning(error.message))
|
dispatch(displayWarning(error.message))
|
||||||
@ -1186,16 +1192,14 @@ export function showAccountDetail (address) {
|
|||||||
const currentTabIsConnectedToNextAddress = permittedAccountsForCurrentTab.includes(address)
|
const currentTabIsConnectedToNextAddress = permittedAccountsForCurrentTab.includes(address)
|
||||||
const switchingToUnconnectedAddress = currentTabIsConnectedToPreviousAddress && !currentTabIsConnectedToNextAddress
|
const switchingToUnconnectedAddress = currentTabIsConnectedToPreviousAddress && !currentTabIsConnectedToNextAddress
|
||||||
|
|
||||||
let tokens
|
|
||||||
try {
|
try {
|
||||||
tokens = await promisifiedBackground.setSelectedAddress(address)
|
await _setSelectedAddress(dispatch, address)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(hideLoadingIndication())
|
dispatch(hideLoadingIndication())
|
||||||
dispatch(displayWarning(error.message))
|
dispatch(displayWarning(error.message))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dispatch(hideLoadingIndication())
|
dispatch(hideLoadingIndication())
|
||||||
dispatch(updateTokens(tokens))
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
type: actionConstants.SHOW_ACCOUNT_DETAIL,
|
||||||
value: address,
|
value: address,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user