mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
deregister sw when update is ready to go to force activating on iOS
This commit is contained in:
parent
6b15e7e3ba
commit
3354d601d1
18
index.html
18
index.html
@ -31,19 +31,19 @@
|
||||
</script>
|
||||
<script id="service-worker" type="module">
|
||||
if('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('sw.js')
|
||||
.then(function(registration) {
|
||||
navigator.serviceWorker.register('sw.js').then(function(registration) {
|
||||
console.log("Service Worker registered");
|
||||
function tryActivateUpdate() {
|
||||
if (registration.waiting && registration.active) {
|
||||
registration.unregister();
|
||||
console.log("Service Worker unregistered");
|
||||
}
|
||||
}
|
||||
tryActivateUpdate();
|
||||
registration.onupdatefound = function() {
|
||||
const newWorker = registration.installing;
|
||||
alert("update found!");
|
||||
newWorker.onstatechange = function() {
|
||||
if (newWorker.state === "installed") {
|
||||
alert("new worker is now on state " + newWorker.state);
|
||||
// if (confirm("update installed! shall I skip waiting?")) {
|
||||
// newWorker.skipWaiting();
|
||||
// }
|
||||
}
|
||||
tryActivateUpdate();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user