Skip to content

Commit c7d0997

Browse files
committed
chore: add localstorage util
1 parent c668dd2 commit c7d0997

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/utils/localStorage.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export class LocalStorage {
2+
static get(key: string) {
3+
if (typeof localStorage === 'undefined') {
4+
return undefined
5+
}
6+
7+
return localStorage.getItem(key)
8+
}
9+
static set(key: string, value: string) {
10+
if (typeof localStorage === 'undefined') {
11+
return undefined
12+
}
13+
14+
return localStorage.setItem(key, value)
15+
}
16+
}

src/utils/notifications.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NotifyClient } from '@walletconnect/notify-client'
22

33
import { localStorageKeys } from '@/constants/localStorage'
4+
import { LocalStorage } from '@/utils/localStorage'
45
import { notificationPwaModalService } from '@/utils/store'
56

67
import { getFirebaseToken } from './firebase'
@@ -63,12 +64,12 @@ export const setupSubscriptionsSymkeys = async (topicSymkeyEntries: [string, str
6364
}
6465

6566
export const closeNotificationModal = () => {
66-
localStorage.setItem(localStorageKeys.notificationModalClosed, 'true')
67+
LocalStorage.set(localStorageKeys.notificationModalClosed, 'true')
6768
notificationPwaModalService.closeModal()
6869
}
6970

7071
export const checkIfNotificationModalClosed = () => {
71-
const storageValue = localStorage.getItem(localStorageKeys.notificationModalClosed)
72+
const storageValue = LocalStorage.get(localStorageKeys.notificationModalClosed)
7273
return storageValue === 'true'
7374
}
7475

0 commit comments

Comments
 (0)