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

Return Promise from editRpc thunk

`editRpc` returned a thunk that didn't return a Promise, despite doing
async work. It now returns a Promise.

In the one place where this is used, it didn't seem important to update
the callsite to block on this finishing. Only one call followed it in
the event handler, and it didn't seem to depend on this.
This commit is contained in:
Mark Stacey 2020-04-24 09:48:59 -03:00
parent 46d72d17a9
commit bd50dabad9

View File

@ -1461,25 +1461,30 @@ export function updateAndSetCustomRpc (newRpc, chainId, ticker = 'ETH', nickname
}
export function editRpc (oldRpc, newRpc, chainId, ticker = 'ETH', nickname, rpcPrefs) {
return (dispatch) => {
return async (dispatch) => {
log.debug(`background.delRpcTarget: ${oldRpc}`)
background.delCustomRpc(oldRpc, (err) => {
if (err) {
log.error(err)
return dispatch(displayWarning('Had a problem removing network!'))
try {
promisifiedBackground.delCustomRpc(oldRpc)
} catch (error) {
log.error(error)
dispatch(displayWarning('Had a problem removing network!'))
return
}
dispatch(setSelectedToken())
background.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, rpcPrefs, (err) => {
if (err) {
log.error(err)
return dispatch(displayWarning('Had a problem changing networks!'))
try {
await promisifiedBackground.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, rpcPrefs)
} catch (error) {
log.error(error)
dispatch(displayWarning('Had a problem changing networks!'))
return
}
dispatch({
type: actionConstants.SET_RPC_TARGET,
value: newRpc,
})
})
})
}
}