Skip to content

Commit

Permalink
fix(storage): delete wrong keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed May 9, 2023
1 parent 212fd43 commit 2a867df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/client-storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export function set<T extends unknown>(
const strResolved = options.compress ? lz.compress(str) : str

if (options.schema === 'indexeddb') {
localStorage.removeItem(key)

indexeddb
.set(key, strResolved)
.then((value) => {
Expand All @@ -25,7 +27,10 @@ export function set<T extends unknown>(
return
}

indexeddb.del(key).catch(() => {})
localStorage.setItem(key, strResolved)

res(key)
})
}

Expand Down

0 comments on commit 2a867df

Please sign in to comment.