Update save convert to check when to reload

pull/1/head
Made Baruna 2021-05-18 17:15:56 +08:00
parent 309f50a5ab
commit d165d8161e
No known key found for this signature in database
GPG Key ID: 5AA5DA16AA5DCEAD
1 changed files with 9 additions and 1 deletions

View File

@ -71,6 +71,7 @@ const convertSave = async () => {
const converted = localStorage.getItem(CONVERTED_KEY); const converted = localStorage.getItem(CONVERTED_KEY);
if (converted !== null) return; if (converted !== null) return;
let convertedCount = 0;
for (const [key, value] of Object.entries(localStorage)) { for (const [key, value] of Object.entries(localStorage)) {
if (key.endsWith('ar') || key.endsWith('wl')) { if (key.endsWith('ar') || key.endsWith('wl')) {
await localforage.setItem(key, Number(value)); await localforage.setItem(key, Number(value));
@ -94,10 +95,17 @@ const convertSave = async () => {
} else { } else {
await localforage.setItem(key, JSON.parse(value)); await localforage.setItem(key, JSON.parse(value));
} }
if (!key.endsWith('locale')) {
convertedCount++;
}
} }
localStorage.setItem(CONVERTED_KEY, dayjs().toISOString()); localStorage.setItem(CONVERTED_KEY, dayjs().toISOString());
if (convertedCount > 0) {
window.location.reload(); window.location.reload();
}
}; };
export const checkLocalSave = async () => { export const checkLocalSave = async () => {