Check if we have a service worker available before trying to communicate with it
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kolaente 2020-06-21 13:19:54 +02:00
parent 83fcd72976
commit 8a7ecfa3bb
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -329,13 +329,15 @@
// Service worker communication // Service worker communication
document.addEventListener(swEvents.SW_UPDATED, this.showRefreshUI, {once: true}) document.addEventListener(swEvents.SW_UPDATED, this.showRefreshUI, {once: true})
navigator.serviceWorker.addEventListener( if (navigator && navigator.serviceWorker) {
'controllerchange', () => { navigator.serviceWorker.addEventListener(
if (this.refreshing) return; 'controllerchange', () => {
this.refreshing = true; if (this.refreshing) return;
window.location.reload(); this.refreshing = true;
} window.location.reload();
); }
)
}
// Try renewing the token every time vikunja is loaded initially // Try renewing the token every time vikunja is loaded initially
// (When opening the browser the focus event is not fired) // (When opening the browser the focus event is not fired)
@ -344,7 +346,7 @@
// Check if the token is still valid if the window gets focus again to maybe renew it // Check if the token is still valid if the window gets focus again to maybe renew it
window.addEventListener('focus', () => { window.addEventListener('focus', () => {
if(!this.userAuthenticated) { if (!this.userAuthenticated) {
return return
} }