Merge pull request #697 from KKishikawa/fix/restore-opend-tabs-correctly

fix: localStorageGabageCollector not working
This commit is contained in:
Infinity 2024-01-26 00:45:45 +01:00 committed by GitHub
commit beb1a00874
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,12 +3,12 @@ import localforage from 'localforage';
export default async function localStorageGarbageCollector() {
const openedTabsJson = await localforage.getItem('openedTabs');
let openedTabs = openedTabsJson ? JSON.parse(openedTabsJson) : [];
let openedTabs = openedTabsJson ?? [];
const closeLimit = moment().add(-7, 'day').valueOf();
openedTabs = openedTabs.filter(x => !x.closedTime || x.closedTime > closeLimit);
await localforage.setItem('openedTabs', JSON.stringify(openedTabs));
await localforage.setItem('openedTabs', openedTabs);
const toRemove = [];
for (const key in localStorage) {