From 55e8cc3bb8ab28b14f49c585ec8d4fcfd755bf6c Mon Sep 17 00:00:00 2001 From: Adrian Gruntkowski Date: Sun, 8 Dec 2024 12:34:35 +0100 Subject: [PATCH] Add ability to easily reset caches and worker --- priv/static/index.html | 3 +++ priv/static/js/jenot.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/priv/static/index.html b/priv/static/index.html index 063342f..638ad82 100644 --- a/priv/static/index.html +++ b/priv/static/index.html @@ -60,6 +60,9 @@ +
+ Reset +
diff --git a/priv/static/js/jenot.js b/priv/static/js/jenot.js index e917477..67b3f3a 100644 --- a/priv/static/js/jenot.js +++ b/priv/static/js/jenot.js @@ -9,6 +9,18 @@ import { } from "./notifications.js"; import "./components.js"; +async function resetApp() { + await window.navigator.serviceWorker + .getRegistration() + .then((r) => r.unregister()); + await caches + .keys() + .then((keys) => Promise.all(keys.map((k) => caches.delete(k)))); + window.location.reload(); +} + +document.querySelector("#reset-app").addEventListener("click", resetApp); + const URL_PARAMS = new URLSearchParams(window.location.search); // Cookie presence determines login state