1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Use async/await for forceUpdateMetamaskState (#8429)

The `forceUpdateMetamaskState` function now uses `async/await` instead
of a Promise constructor. This was done to make an upcoming change
easier (making `updateMetamaskState` async).
This commit is contained in:
Mark Stacey 2020-04-27 18:21:17 -03:00 committed by GitHub
parent f11a5b4808
commit 21d62e3adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1865,19 +1865,19 @@ export function setMouseUserState (isMouseUser) {
}
}
export function forceUpdateMetamaskState (dispatch) {
export async function forceUpdateMetamaskState (dispatch) {
log.debug(`background.getState`)
return new Promise((resolve, reject) => {
background.getState((err, newState) => {
if (err) {
dispatch(displayWarning(err.message))
return reject(err)
}
dispatch(updateMetamaskState(newState))
resolve(newState)
})
})
let newState
try {
newState = await promisifiedBackground.getState()
} catch (error) {
dispatch(displayWarning(error.message))
throw error
}
dispatch(updateMetamaskState(newState))
return newState
}
export function toggleAccountMenu () {