2022-05-26 23:52:04 +03:00
|
|
|
export const LOCAL_STORAGE_KEYS = {
|
|
|
|
username: 'username',
|
2022-05-30 07:52:38 +03:00
|
|
|
hasDisplayedNotificationModal: 'HAS_DISPLAYED_NOTIFICATION_MODAL',
|
2022-06-27 09:01:52 +03:00
|
|
|
userVisitCount: 'USER_VISIT_COUNT',
|
2022-05-26 23:52:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export function getLocalStorage(key) {
|
|
|
|
try {
|
|
|
|
return localStorage.getItem(key);
|
2023-05-21 07:15:25 +03:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
2022-05-26 23:52:04 +03: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-21 07:15:25 +03:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
2022-05-26 23:52:04 +03:00
|
|
|
}
|
2023-05-21 07:15:25 +03:00
|
|
|
return false;
|
2022-05-26 23:52:04 +03:00
|
|
|
}
|