From 6784c7c9e2b977b036ad87ef17e2f0b2e919a740 Mon Sep 17 00:00:00 2001 From: Mike Tobia Date: Mon, 24 Aug 2020 16:37:03 -0400 Subject: [PATCH] fix(pwa): reset config when not supplied (#283) --- src/server/middleware/pwa/config.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/server/middleware/pwa/config.js b/src/server/middleware/pwa/config.js index 535eb98c..cc178514 100644 --- a/src/server/middleware/pwa/config.js +++ b/src/server/middleware/pwa/config.js @@ -40,6 +40,13 @@ function setPWAConfig(newConfiguration) { } function createServiceWorkerConfig(config) { + if (!config) { + // if there was no config given or a previous configuration present, we want to + // gracefully remove any remaining instances. We currently handle this client side + // and would only need to reset the configuration when we want to decouple. + return resetPWAConfig(); + } + let enabled = false; let scope = null; let type = null; @@ -111,14 +118,6 @@ export function configurePWA(config = {}) { config = null; } - if (!config && pwaConfig.serviceWorker) { - // if there was a previous configuration present, we want to gracefully - // remove any remaining instances. We currently handle this client side - // and would only need to reset the configuration when we want to decouple. - // eslint-disable-next-line no-param-reassign - config = resetPWAConfig(); - } - const serviceWorkerConfig = createServiceWorkerConfig(config); const { webManifestObject, webManifest,