From 8a7ecfa3bba502421ba26adf8d8d76eb714aa821 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 21 Jun 2020 13:19:54 +0200 Subject: [PATCH] Check if we have a service worker available before trying to communicate with it --- src/App.vue | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/App.vue b/src/App.vue index e5f27f64c..6e83f29e1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -329,13 +329,15 @@ // Service worker communication document.addEventListener(swEvents.SW_UPDATED, this.showRefreshUI, {once: true}) - navigator.serviceWorker.addEventListener( - 'controllerchange', () => { - if (this.refreshing) return; - this.refreshing = true; - window.location.reload(); - } - ); + if (navigator && navigator.serviceWorker) { + navigator.serviceWorker.addEventListener( + 'controllerchange', () => { + if (this.refreshing) return; + this.refreshing = true; + window.location.reload(); + } + ) + } // Try renewing the token every time vikunja is loaded initially // (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 window.addEventListener('focus', () => { - if(!this.userAuthenticated) { + if (!this.userAuthenticated) { return }