Skip to content

Commit

Permalink
fix: update storage key
Browse files Browse the repository at this point in the history
  • Loading branch information
b3aton committed Dec 5, 2022
1 parent b50e4f4 commit ae00ef4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/storefront/src/utils/b3Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@ enum StorageType {
class MyStorage {
storage: Storage

prefix: string

constructor(type: StorageType) {
this.storage = type === StorageType.l ? window.localStorage : window.sessionStorage
this.prefix = 'sf-'
}

set(
key: string,
value: any,
) {
const data = JSON.stringify(value)
this.storage.setItem(key, data)
this.storage.setItem(this.prefix + key, data)
}

get(key: string) {
const value = this.storage.getItem(key)
const value = this.storage.getItem(this.prefix + key)
if (value) {
return JSON.parse(value)
}
}

delete(key: string) {
this.storage.removeItem(key)
this.storage.removeItem(this.prefix + key)
}

clear() {
Expand Down

0 comments on commit ae00ef4

Please sign in to comment.