Adds fallback to USD as currency rate selected in case that the data stored is not defined

This commit is contained in:
Agustin Pane 2020-06-04 10:49:12 -03:00
parent 6858a8d6d6
commit 1a901126df

View File

@ -23,9 +23,16 @@ export const fetchCurrencyValues = (safeAddress: string) => async (dispatch) =>
const safeAddr = kv[0]
const value = kv[1]
const { currencyRate, selectedCurrency }: CurrencyRateValue = value
let { currencyRate, selectedCurrency }: CurrencyRateValue = value
// Fallback for users that got an undefined saved on localStorage
if (!selectedCurrency || selectedCurrency === AVAILABLE_CURRENCIES.USD) {
currencyRate = 1
selectedCurrency = AVAILABLE_CURRENCIES.USD
}
batch(() => {
dispatch(setSelectedCurrency(safeAddr, selectedCurrency || AVAILABLE_CURRENCIES.USD))
dispatch(setSelectedCurrency(safeAddr, selectedCurrency))
dispatch(setCurrencyRate(safeAddr, currencyRate))
})
})