Forcing a refresh on new SW

This commit is contained in:
Kasper Rynning-Tønnesen
2020-02-14 12:47:48 +01:00
parent 37eb15991f
commit eed8a84092

View File

@@ -24,6 +24,19 @@ export default {
"Arbeids arbeideren din er installert. Du kan nå gå offline frem til neste trekning."
);
serviceWorker.onupdatefound = () => {
const installingWorker = serviceWorker.installing;
installingWorker.onstatechange = () => {
if (
installingWorker.state === "installed" &&
navigator.serviceWorker.controller
) {
// Preferably, display a message asking the user to reload...
location.reload();
}
};
};
if (!("PushManager" in window)) {
throw new Error("No Push API Support!");
}