2022-08-05 08:16:12 +00:00
|
|
|
export const LOCAL_STORAGE_KEYS = {
|
|
|
|
DISMISSED_UPDATES: 'dismissedUpdates',
|
|
|
|
WIDGET_BUILDER: 'widgetBubble_',
|
|
|
|
};
|
2022-03-15 15:39:14 +00:00
|
|
|
|
2022-08-05 08:16:12 +00:00
|
|
|
export const LocalStorage = {
|
|
|
|
clearAll() {
|
|
|
|
window.localStorage.clear();
|
|
|
|
},
|
2022-03-15 15:39:14 +00:00
|
|
|
|
2022-08-05 08:16:12 +00:00
|
|
|
get(key) {
|
|
|
|
const value = window.localStorage.getItem(key);
|
|
|
|
try {
|
|
|
|
return typeof value === 'string' ? JSON.parse(value) : value;
|
|
|
|
} catch (error) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
set(key, value) {
|
|
|
|
if (typeof value === 'object') {
|
|
|
|
window.localStorage.setItem(key, JSON.stringify(value));
|
|
|
|
} else {
|
|
|
|
window.localStorage.setItem(key, value);
|
|
|
|
}
|
|
|
|
window.localStorage.setItem(key + ':ts', Date.now());
|
|
|
|
},
|
2022-03-15 15:39:14 +00:00
|
|
|
|
2022-08-05 08:16:12 +00:00
|
|
|
remove(key) {
|
|
|
|
window.localStorage.removeItem(key);
|
|
|
|
window.localStorage.removeItem(key + ':ts');
|
|
|
|
},
|
|
|
|
};
|