2022-05-26 13:52:04 -07:00
|
|
|
export const LOCAL_STORAGE_KEYS = {
|
|
|
|
username: 'username',
|
2022-05-29 21:52:38 -07:00
|
|
|
hasDisplayedNotificationModal: 'HAS_DISPLAYED_NOTIFICATION_MODAL',
|
2022-06-26 23:01:52 -07:00
|
|
|
userVisitCount: 'USER_VISIT_COUNT',
|
2022-05-26 13:52:04 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
export function getLocalStorage(key) {
|
|
|
|
try {
|
|
|
|
return localStorage.getItem(key);
|
2023-05-20 21:15:25 -07:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
2022-05-26 13:52:04 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setLocalStorage(key, value) {
|
|
|
|
try {
|
|
|
|
if (value !== '' && value !== null) {
|
|
|
|
localStorage.setItem(key, value);
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem(key);
|
|
|
|
}
|
|
|
|
return true;
|
2023-05-20 21:15:25 -07:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
2022-05-26 13:52:04 -07:00
|
|
|
}
|
2023-05-20 21:15:25 -07:00
|
|
|
return false;
|
2022-05-26 13:52:04 -07:00
|
|
|
}
|