new service worker

This commit is contained in:
Alberto Xamin 2021-01-24 15:19:59 +01:00
parent 1c61d8f1eb
commit 56a456b58e
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
2 changed files with 11 additions and 13 deletions

View File

@ -51,7 +51,7 @@ export default {
} else {
(new Audio(notification_sfx)).play();
}
}else {
} else { // a chat message
(new Audio(message_sfx)).play();
this.messages.push(msg);
}

View File

@ -1,17 +1,15 @@
import { Workbox } from "workbox-window";
import { Workbox } from 'workbox-window';
let wb;
if ('serviceWorker' in navigator) {
const wb = new Workbox('service-worker.js');
if ("serviceWorker" in navigator) {
wb = new Workbox(`${process.env.BASE_URL}service-worker.js`);
wb.addEventListener("controlling", () => {
window.location.reload();
wb.addEventListener('installed', event => {
if (event.isUpdate) {
if (confirm(`Update available. Click OK to update`)) {
window.location.reload();
}
}
});
wb.register();
} else {
wb = null;
}
export default wb;