124390a019
Co-authored-by: Aswin Dev P.S <aswindevps@gmail.com>
32 lines
760 B
JavaScript
32 lines
760 B
JavaScript
export const LOCAL_STORAGE_KEYS = {
|
|
DISMISSED_UPDATES: 'dismissedUpdates',
|
|
WIDGET_BUILDER: 'widgetBubble_',
|
|
};
|
|
|
|
export const LocalStorage = {
|
|
clearAll() {
|
|
window.localStorage.clear();
|
|
},
|
|
|
|
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());
|
|
},
|
|
|
|
remove(key) {
|
|
window.localStorage.removeItem(key);
|
|
window.localStorage.removeItem(key + ':ts');
|
|
},
|
|
};
|