feat: dismiss label suggestions only for 24 hours (#7579)
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user