new service worker
This commit is contained in:
parent
1c61d8f1eb
commit
56a456b58e
@ -51,7 +51,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
(new Audio(notification_sfx)).play();
|
(new Audio(notification_sfx)).play();
|
||||||
}
|
}
|
||||||
}else {
|
} else { // a chat message
|
||||||
(new Audio(message_sfx)).play();
|
(new Audio(message_sfx)).play();
|
||||||
this.messages.push(msg);
|
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.addEventListener('installed', event => {
|
||||||
wb = new Workbox(`${process.env.BASE_URL}service-worker.js`);
|
if (event.isUpdate) {
|
||||||
|
if (confirm(`Update available. Click OK to update`)) {
|
||||||
wb.addEventListener("controlling", () => {
|
window.location.reload();
|
||||||
window.location.reload();
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
wb.register();
|
wb.register();
|
||||||
} else {
|
|
||||||
wb = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default wb;
|
|
Loading…
Reference in New Issue
Block a user