From 24499e530ac2ba2eaa13ccbfbe9653ac001b4d70 Mon Sep 17 00:00:00 2001 From: yaso Date: Wed, 18 Sep 2024 14:06:10 +0200 Subject: [PATCH] sw v2 --- Frontend/patient_manager/web/index.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Frontend/patient_manager/web/index.html b/Frontend/patient_manager/web/index.html index 77aee47e..d9d21c67 100644 --- a/Frontend/patient_manager/web/index.html +++ b/Frontend/patient_manager/web/index.html @@ -152,16 +152,18 @@ } }); } - console.log('Latest Service Worker Version: ' + serviceWorkerVersion); - console.log('Active Service Worker and Version: ' + reg.active.scriptURL); - const isMatch = reg.active.scriptURL.endsWith(serviceWorkerVersion) + console.log('Active Service Worker URL: ' + reg.active.scriptURL); + const currentSWVersion = reg.active.scriptURL.split("=")[1]; + console.log('Active Service Worker Version: ' + serviceWorkerVersion); + console.log('Latest Service Worker Version: ' + currentSWVersion); + const isMatch = currentSWVersion === serviceWorkerVersion; console.log('On Latest Service Woprker: ' + isMatch); if (!reg.active && (reg.installing || reg.waiting)) { // No active web worker and we have installed or are installing // one for the first time. Simply wait for it to activate. - console.log('Installing service worker.'); + console.log('No Service Worker Available - Installing New Service Worker.'); waitForActivation(reg.installing || reg.waiting); - } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) { + } else if (!isMatch) { // When the app updates the serviceWorkerVersion changes, so we // need to ask the service worker to update. console.log('New service worker available.');