typing loadFromStorage wip
This commit is contained in:
parent
231a9a7d35
commit
18f03b8bc1
|
@ -10,10 +10,10 @@ const watchedActions = [ADD_PROVIDER, REMOVE_PROVIDER]
|
||||||
|
|
||||||
const LAST_USED_PROVIDER_KEY = 'LAST_USED_PROVIDER'
|
const LAST_USED_PROVIDER_KEY = 'LAST_USED_PROVIDER'
|
||||||
|
|
||||||
export const loadLastUsedProvider = async () => {
|
export const loadLastUsedProvider = async (): Promise<string | undefined> => {
|
||||||
const lastUsedProvider = await loadFromStorage(LAST_USED_PROVIDER_KEY)
|
const lastUsedProvider = await loadFromStorage<string>(LAST_USED_PROVIDER_KEY)
|
||||||
|
|
||||||
return lastUsedProvider || ''
|
return lastUsedProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
let watcherInterval = null
|
let watcherInterval = null
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const storage = new ImmortalStorage(stores)
|
||||||
|
|
||||||
const PREFIX = `v2_${getNetwork()}`
|
const PREFIX = `v2_${getNetwork()}`
|
||||||
|
|
||||||
export const loadFromStorage = async <T extends () => unknown>(key: string): Promise<T> => {
|
export const loadFromStorage = async <T extends unknown>(key: string): Promise<T | undefined> => {
|
||||||
try {
|
try {
|
||||||
const stringifiedValue = await storage.get(`${PREFIX}__${key}`)
|
const stringifiedValue = await storage.get(`${PREFIX}__${key}`)
|
||||||
if (stringifiedValue === null || stringifiedValue === undefined) {
|
if (stringifiedValue === null || stringifiedValue === undefined) {
|
||||||
|
|
Loading…
Reference in New Issue