mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Return promise from setCurrentCurrency
thunk (#8420)
`setCurrentCurrency` returned a thunk that didn't return a Promise, despite doing async work. It now returns a Promise. The callers in this case never needed to know when this action had completed, but at least this makes our tests more reliable. They were already `await`-ing this action, despite the lack of Promise.
This commit is contained in:
parent
b4c6c11267
commit
ee3f6f124e
@ -408,23 +408,26 @@ export function showQrScanner () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setCurrentCurrency (currencyCode) {
|
export function setCurrentCurrency (currencyCode) {
|
||||||
return (dispatch) => {
|
return async (dispatch) => {
|
||||||
dispatch(showLoadingIndication())
|
dispatch(showLoadingIndication())
|
||||||
log.debug(`background.setCurrentCurrency`)
|
log.debug(`background.setCurrentCurrency`)
|
||||||
background.setCurrentCurrency(currencyCode, (err, data) => {
|
let data
|
||||||
|
try {
|
||||||
|
data = await promisifiedBackground.setCurrentCurrency(currencyCode)
|
||||||
|
} catch (error) {
|
||||||
dispatch(hideLoadingIndication())
|
dispatch(hideLoadingIndication())
|
||||||
if (err) {
|
log.error(error.stack)
|
||||||
log.error(err.stack)
|
dispatch(displayWarning(error.message))
|
||||||
return dispatch(displayWarning(err.message))
|
return
|
||||||
}
|
}
|
||||||
dispatch({
|
dispatch(hideLoadingIndication())
|
||||||
type: actionConstants.SET_CURRENT_FIAT,
|
dispatch({
|
||||||
value: {
|
type: actionConstants.SET_CURRENT_FIAT,
|
||||||
currentCurrency: data.currentCurrency,
|
value: {
|
||||||
conversionRate: data.conversionRate,
|
currentCurrency: data.currentCurrency,
|
||||||
conversionDate: data.conversionDate,
|
conversionRate: data.conversionRate,
|
||||||
},
|
conversionDate: data.conversionDate,
|
||||||
})
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user