Browse Source

Memoize currencySettingsLocaleSelector result

master
meriadec 7 years ago
parent
commit
74e1d1d56b
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 9
      src/reducers/settings.js

9
src/reducers/settings.js

@ -177,12 +177,19 @@ export const getOrderAccounts = (state: State) => state.settings.orderAccounts
export const areSettingsLoaded = (state: State) => state.settings.loaded
// TODO: avoid this memoize hack (i thought reselect was doing it for us)
const __memoizedCurrencySettingsLocaleValues = {}
export const currencySettingsLocaleSelector = (
settings: SettingsState,
currency: Currency,
): CurrencySettings => {
if (__memoizedCurrencySettingsLocaleValues[currency.id]) {
return __memoizedCurrencySettingsLocaleValues[currency.id]
}
const currencySettings = settings.currenciesSettings[currency.id]
return { ...defaultsForCurrency(currency), ...currencySettings }
const val = { ...defaultsForCurrency(currency), ...currencySettings }
__memoizedCurrencySettingsLocaleValues[currency.id] = val
return val
}
type CSS = Selector<*, { currency: CryptoCurrency }, CurrencySettings>

Loading…
Cancel
Save