Return Promise from `updateAndSetCustomRpc` thunk (#8440)

`updateAndSetCustomRpc` 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.
feature/default_network_editable
Mark Stacey 5 years ago committed by GitHub
parent 06ba0db840
commit 47b785ad7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      ui/app/store/actions.js

@ -1445,17 +1445,20 @@ export function setPreviousProvider (type) {
} }
export function updateAndSetCustomRpc (newRpc, chainId, ticker = 'ETH', nickname, rpcPrefs) { export function updateAndSetCustomRpc (newRpc, chainId, ticker = 'ETH', nickname, rpcPrefs) {
return (dispatch) => { return async (dispatch) => {
log.debug(`background.updateAndSetCustomRpc: ${newRpc} ${chainId} ${ticker} ${nickname}`) log.debug(`background.updateAndSetCustomRpc: ${newRpc} ${chainId} ${ticker} ${nickname}`)
background.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, rpcPrefs, (err) => {
if (err) { try {
log.error(err) await promisifiedBackground.updateAndSetCustomRpc(newRpc, chainId, ticker, nickname || newRpc, rpcPrefs)
return dispatch(displayWarning('Had a problem changing networks!')) } catch (error) {
} log.error(error)
dispatch({ dispatch(displayWarning('Had a problem changing networks!'))
type: actionConstants.SET_RPC_TARGET, return
value: newRpc, }
})
dispatch({
type: actionConstants.SET_RPC_TARGET,
value: newRpc,
}) })
} }
} }

Loading…
Cancel
Save