WA-232 remove token from localStorage
This commit is contained in:
parent
043505183f
commit
fdf32fcdbb
|
@ -51,3 +51,17 @@ export const setToken = (safeAddress: string, token: Token) => {
|
||||||
console.log('Error adding token in localstorage')
|
console.log('Error adding token in localstorage')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const removeTokenFromStorage = (safeAddress: string, token: Token) => {
|
||||||
|
const data: List<TokenProps> = getTokens(safeAddress)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const index = data.indexOf(token)
|
||||||
|
const serializedState = JSON.stringify(data.remove(index))
|
||||||
|
const key = getTokensKey(safeAddress)
|
||||||
|
localStorage.setItem(key, serializedState)
|
||||||
|
} catch (err) {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
console.log('Error removing token in localstorage')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue