new service worker
This commit is contained in:
parent
1c61d8f1eb
commit
56a456b58e
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user