From 30fa15e36788cb8983b114e9d681f730e7a3f95d Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Sun, 5 Dec 2021 01:29:29 +0700 Subject: [PATCH] Fix save file got bigger everytime because of backup --- src/routes/wish/import.svelte | 4 ++-- src/stores/saveManager.js | 7 +++++++ src/template.html | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/routes/wish/import.svelte b/src/routes/wish/import.svelte index 34698b12..0fed1dcf 100644 --- a/src/routes/wish/import.svelte +++ b/src/routes/wish/import.svelte @@ -304,8 +304,8 @@ calculatingPity = true; // backup first - const oldData = await getLocalSaveJson(); - await updateSave(`${prefix}backup`, oldData); + // const oldData = await getLocalSaveJson(); + // await updateSave(`${prefix}backup`, oldData); for (let [code, type] of Object.entries(types)) { await processWishes(code, type); diff --git a/src/stores/saveManager.js b/src/stores/saveManager.js index 8ae08ab9..de0d8f58 100644 --- a/src/stores/saveManager.js +++ b/src/stores/saveManager.js @@ -68,6 +68,13 @@ const convertTime = (data) => { }; const convertSave = async () => { + const lfkeys = await localforage.keys(); + for (const key of lfkeys) { + if (key.includes('backup')) { + await localforage.removeItem(key); + } + } + const converted = localStorage.getItem(CONVERTED_KEY); if (converted !== null) return; diff --git a/src/template.html b/src/template.html index 8329f17c..35b702ec 100644 --- a/src/template.html +++ b/src/template.html @@ -50,8 +50,8 @@ - - + +