Revert "feat: Adds support for draft in conversation reply box (#4205)" (#4425)

This reverts commit 5ea0436051.
This commit is contained in:
Pranav Raj S 2022-04-08 15:52:39 +05:30 committed by GitHub
parent 7e5ec7925c
commit bc7bcc20b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 24 additions and 202 deletions

View file

@ -1,32 +1,17 @@
export const LOCAL_STORAGE_KEYS = {
DISMISSED_UPDATES: 'dismissedUpdates',
DRAFT_MESSAGES: 'draftMessages',
};
class LocalStorage {
constructor(key) {
this.key = key;
}
export const LocalStorage = {
clearAll() {
window.localStorage.clear();
},
store(allItems) {
localStorage.setItem(this.key, JSON.stringify(allItems));
localStorage.setItem(this.key + ':ts', Date.now());
}
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());
},
get() {
let stored = localStorage.getItem(this.key);
return JSON.parse(stored) || [];
}
}
remove(key) {
window.localStorage.removeItem(key);
window.localStorage.removeItem(key + ':ts');
},
};
export default LocalStorage;