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) {
|
||||
return (dispatch) => {
|
||||
return async (dispatch) => {
|
||||
dispatch(showLoadingIndication())
|
||||
log.debug(`background.setCurrentCurrency`)
|
||||
background.setCurrentCurrency(currencyCode, (err, data) => {
|
||||
let data
|
||||
try {
|
||||
data = await promisifiedBackground.setCurrentCurrency(currencyCode)
|
||||
} catch (error) {
|
||||
dispatch(hideLoadingIndication())
|
||||
if (err) {
|
||||
log.error(err.stack)
|
||||
return dispatch(displayWarning(err.message))
|
||||
}
|
||||
dispatch({
|
||||
type: actionConstants.SET_CURRENT_FIAT,
|
||||
value: {
|
||||
currentCurrency: data.currentCurrency,
|
||||
conversionRate: data.conversionRate,
|
||||
conversionDate: data.conversionDate,
|
||||
},
|
||||
})
|
||||
log.error(error.stack)
|
||||
dispatch(displayWarning(error.message))
|
||||
return
|
||||
}
|
||||
dispatch(hideLoadingIndication())
|
||||
dispatch({
|
||||
type: actionConstants.SET_CURRENT_FIAT,
|
||||
value: {
|
||||
currentCurrency: data.currentCurrency,
|
||||
conversionRate: data.conversionRate,
|
||||
conversionDate: data.conversionDate,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user