From 905295a0452e3619707570c71c4558b83bea747d Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 18 Sep 2024 13:20:08 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20wrong=20"once"=20logic=20=F0=9F=A4=A6?= =?UTF-8?q?=E2=80=8D=E2=99=82=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.jsx b/src/main.jsx index df3f9249..65388245 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -52,7 +52,7 @@ setTimeout(() => { if ('serviceWorker' in navigator && typeof caches !== 'undefined') { const MAX_SW_CACHE_SIZE = 50; const IGNORE_CACHE_KEYS = ['icons']; - let clearedOnce = false; + let clearRanOnce = false; const FAST_INTERVAL = 10_000; // 10 seconds const SLOW_INTERVAL = 60 * 60 * 1000; // 1 hour async function clearCaches() { @@ -69,13 +69,13 @@ if ('serviceWorker' in navigator && typeof caches !== 'undefined') { for (const deleteKey of deleteKeys) { await cache.delete(deleteKey); } - clearedOnce = true; } } + clearRanOnce = true; } catch (e) {} // Silent fail } // Once cleared, clear again at slower interval - setTimeout(clearCaches, clearedOnce ? SLOW_INTERVAL : FAST_INTERVAL); + setTimeout(clearCaches, clearRanOnce ? SLOW_INTERVAL : FAST_INTERVAL); } setTimeout(clearCaches, FAST_INTERVAL); }