rename setActiveTokens to saveActiveTokens

This commit is contained in:
mmv 2019-04-17 18:40:30 +04:00
parent 43e8521aba
commit c633165dd2
4 changed files with 6 additions and 14 deletions

View File

@ -1,7 +1,7 @@
// @flow
import { createAction } from 'redux-actions'
import { type Token } from '~/logic/tokens/store/model/token'
import { setActiveTokens, getActiveTokens, setToken } from '~/logic/tokens/utils/tokensStorage'
import { saveActiveTokens, getActiveTokens, setToken } from '~/logic/tokens/utils/tokensStorage'
import type { Dispatch as ReduxDispatch } from 'redux'
import { type GlobalState } from '~/store/'
@ -23,7 +23,7 @@ const saveToken = (safeAddress: string, token: Token) => async (dispatch: ReduxD
dispatch(addToken(token))
const activeTokens = await getActiveTokens(safeAddress)
await setActiveTokens(safeAddress, activeTokens.push(token.toJS()))
await saveActiveTokens(safeAddress, activeTokens.push(token.toJS()))
setToken(safeAddress, token)
}

View File

@ -10,7 +10,7 @@ export const CUSTOM_TOKENS_KEY = 'CUSTOM_TOKENS'
// to avoid iterating a large amount of data of tokens from the backend
// Custom tokens should be saved too unless they're deleted (marking them as inactive doesn't count)
export const setActiveTokens = async (tokens: Map<string, Token>) => {
export const saveActiveTokens = async (tokens: Map<string, Token>) => {
try {
await saveToStorage(ACTIVE_TOKENS_KEY, tokens.toJS())
} catch (err) {
@ -59,6 +59,6 @@ export const removeFromActiveTokens = async (safeAddress: string, token: Token)
const index = activeTokens.findIndex(activeToken => activeToken.name === token.name)
if (index !== -1) {
await setActiveTokens(safeAddress, activeTokens.delete(index))
await saveActiveTokens(safeAddress, activeTokens.delete(index))
}
}

View File

@ -1,8 +0,0 @@
// @flow
import { createAction } from 'redux-actions'
export const UPDATE_SAFES = 'UPDATE_SAFES'
const updateSafesInBatch = createAction<string, *>(UPDATE_SAFES)
export default updateSafesInBatch

View File

@ -8,7 +8,7 @@ import { safesMapSelector } from '~/routes/safeList/store/selectors'
import { getActiveTokensAddressesForAllSafes } from '~/routes/safe/store/selectors'
import { tokensSelector } from '~/logic/tokens/store/selectors'
import type { Token } from '~/logic/tokens/store/model/token'
import { setActiveTokens } from '~/logic/tokens/utils/tokensStorage'
import { saveActiveTokens } from '~/logic/tokens/utils/tokensStorage'
const watchedActions = [ADD_SAFE, UPDATE_SAFE]
@ -33,7 +33,7 @@ const safeStorageMware = (store: Store<GlobalState>) => (next: Function) => asyn
})
})
setActiveTokens(activeTokens)
saveActiveTokens(activeTokens)
}
if (action.type === ADD_SAFE) {