Chatwoot/app/javascript/dashboard/helper/localStorage.js

18 lines
342 B
JavaScript
Raw Normal View History

class LocalStorage {
constructor(key) {
this.key = key;
}
store(allItems) {
localStorage.setItem(this.key, JSON.stringify(allItems));
localStorage.setItem(this.key + ':ts', Date.now());
}
get() {
let stored = localStorage.getItem(this.key);
return JSON.parse(stored) || [];
}
}
export default LocalStorage;