diff --git a/src/logic/safe/utils/safeStorage.js b/src/logic/safe/utils/safeStorage.js index 2301a5e1..3a5ad40e 100644 --- a/src/logic/safe/utils/safeStorage.js +++ b/src/logic/safe/utils/safeStorage.js @@ -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 => { return data ? Map(data) : Map() } + +export const removeOwners = async (safeAddress: string): Map => { + try { + await removeFromStorage(`${OWNERS_KEY}-${safeAddress}`) + } catch (err) { + // eslint-disable-next-line + console.log('Error removing owners from localstorage') + } +} diff --git a/src/utils/storage/index.js b/src/utils/storage/index.js index d1f3f1bf..80d34efe 100644 --- a/src/utils/storage/index.js +++ b/src/utils/storage/index.js @@ -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) + } +}