Session storage shouldn't be undefined in newer browsers
Tried FF incognito
This commit is contained in:
parent
54820689c2
commit
11cc8e46b7
1 changed files with 3 additions and 20 deletions
|
@ -3,31 +3,14 @@ export enum SESSION_KEYS {
|
|||
KEY_ENCRYPTION_KEY = "keyEncryptionKey",
|
||||
}
|
||||
|
||||
export const setKey = (key: SESSION_KEYS, value: object) => {
|
||||
if (typeof sessionStorage === "undefined") {
|
||||
return null;
|
||||
}
|
||||
export const setKey = (key: SESSION_KEYS, value: object) =>
|
||||
sessionStorage.setItem(key, JSON.stringify(value));
|
||||
};
|
||||
|
||||
export const getKey = (key: SESSION_KEYS) => {
|
||||
if (typeof sessionStorage === "undefined") {
|
||||
return null;
|
||||
}
|
||||
const value = sessionStorage.getItem(key);
|
||||
return value && JSON.parse(value);
|
||||
};
|
||||
|
||||
export const removeKey = (key: SESSION_KEYS) => {
|
||||
if (typeof sessionStorage === "undefined") {
|
||||
return null;
|
||||
}
|
||||
sessionStorage.removeItem(key);
|
||||
};
|
||||
export const removeKey = (key: SESSION_KEYS) => sessionStorage.removeItem(key);
|
||||
|
||||
export const clearKeys = () => {
|
||||
if (typeof sessionStorage === "undefined") {
|
||||
return null;
|
||||
}
|
||||
sessionStorage.clear();
|
||||
};
|
||||
export const clearKeys = () => sessionStorage.clear();
|
||||
|
|
Loading…
Reference in a new issue