Remove Safe owners from storage

This commit is contained in:
Germán Martínez 2019-05-22 12:56:11 +02:00
parent 654cc5a0d7
commit 34aa15bee8
2 changed files with 18 additions and 1 deletions

View File

@ -1,7 +1,7 @@
// @flow
import { type Owner } from '~/routes/safe/store/models/owner'
import { List, Map } from 'immutable'
import { loadFromStorage, saveToStorage } from '~/utils/storage'
import { loadFromStorage, saveToStorage, removeFromStorage } from '~/utils/storage'
export const SAFES_KEY = 'SAFES'
export const TX_KEY = 'TX'
@ -41,3 +41,12 @@ export const getOwners = async (safeAddress: string): Map<string, string> => {
return data ? Map(data) : Map()
}
export const removeOwners = async (safeAddress: string): Map<string, string> => {
try {
await removeFromStorage(`${OWNERS_KEY}-${safeAddress}`)
} catch (err) {
// eslint-disable-next-line
console.log('Error removing owners from localstorage')
}
}

View File

@ -31,3 +31,11 @@ export const saveToStorage = async (key: string, value: *): Promise<*> => {
console.error(`Failed to save ${key} in the storage:`, err)
}
}
export const removeFromStorage = async (key: string): Promise<*> => {
try {
await storage.remove(`${PREFIX}__${key}`)
} catch (err) {
console.error(`Failed to remove ${key} from the storage:`, err)
}
}