feat: dismiss label suggestions only for 24 hours (#7579)

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Shivam Mishra
2023-07-24 17:51:09 +05:30
committed by GitHub
parent 56d0b220f4
commit c83105ce4f
6 changed files with 37 additions and 76 deletions

View File

@@ -12,6 +12,7 @@ export const LocalStorage = {
return value;
}
},
set(key, value) {
if (typeof value === 'object') {
window.localStorage.setItem(key, JSON.stringify(value));
@@ -21,6 +22,26 @@ export const LocalStorage = {
window.localStorage.setItem(key + ':ts', Date.now());
},
setFlag(store, accountId, key, expiry = 24 * 60 * 60 * 1000) {
const storeName = accountId ? `${store}::${accountId}` : store;
const rawValue = window.localStorage.getItem(storeName);
const parsedValue = rawValue ? JSON.parse(rawValue) : {};
parsedValue[key] = Date.now() + expiry;
window.localStorage.setItem(storeName, JSON.stringify(parsedValue));
},
getFlag(store, accountId, key) {
const storeName = store ? `${store}::${accountId}` : store;
const rawValue = window.localStorage.getItem(storeName);
const parsedValue = rawValue ? JSON.parse(rawValue) : {};
return parsedValue[key] && parsedValue[key] > Date.now();
},
remove(key) {
window.localStorage.removeItem(key);
window.localStorage.removeItem(key + ':ts');