Skip to content

Commit

Permalink
fix update detection
Browse files Browse the repository at this point in the history
  • Loading branch information
maxence-charriere committed Jul 2, 2023
1 parent ce5db33 commit 7a67d61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
21 changes: 7 additions & 14 deletions pkg/app/gen/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,14 @@ function goappWatchForUpdate() {
}

function goappSetupNotifyUpdate(registration) {
registration.onupdatefound = () => {
const installingWorker = registration.installing;

installingWorker.onstatechange = () => {
if (installingWorker.state != "installed") {
return;
}

if (!navigator.serviceWorker.controller) {
return;
registration.addEventListener("updatefound", (event) => {
const newSW = registration.installing;
newSW.addEventListener("statechange", (event) => {
if (newSW.state == "installed") {
goappOnUpdate();
}

goappOnUpdate();
};
};
});
});
}

function goappSetupAutoUpdate(registration) {
Expand Down
Loading

0 comments on commit 7a67d61

Please sign in to comment.