Add ability to easily reset caches and worker

This commit is contained in:
Adrian Gruntkowski 2024-12-08 12:34:35 +01:00
parent 10fc27e13d
commit 55e8cc3bb8
2 changed files with 15 additions and 0 deletions

View file

@ -60,6 +60,9 @@
</button>
<button id="test-notifications">Send test notification</button>
</div>
<div>
<a href="#" id="reset-app">Reset</a>
</div>
</nav>
<note-form mode="add" id="new-note">

View file

@ -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