From 8b3606c3976d42fac23e2238fef99b3ceae10f28 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 28 Jan 2021 20:37:51 -0600 Subject: [PATCH] fix check for update button not showing this happened when the app starts when it is already up to date --- src/serviceWorkerRegistration.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/serviceWorkerRegistration.ts b/src/serviceWorkerRegistration.ts index bbeffa3e..b2323922 100644 --- a/src/serviceWorkerRegistration.ts +++ b/src/serviceWorkerRegistration.ts @@ -63,6 +63,13 @@ function registerValidSW(swUrl: string, config?: Config): void { navigator.serviceWorker .register(swUrl) .then((registration) => { + if (registration.active) { + // Execute callback + if (config && config.onSuccess) { + config.onSuccess(registration); + } + } + registration.onupdatefound = () => { const installingWorker = registration.installing; if (installingWorker == null) {