From f70c387bf6035e7693c2d3d78222de184c921cc8 Mon Sep 17 00:00:00 2001 From: Milad Hosseinpour Date: Sat, 28 Aug 2021 11:57:34 +0430 Subject: [PATCH 1/2] add auto update to change the app content --- templates/workbox/workbox.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/templates/workbox/workbox.js b/templates/workbox/workbox.js index a332177d..fd71d5f2 100755 --- a/templates/workbox/workbox.js +++ b/templates/workbox/workbox.js @@ -16,3 +16,15 @@ async function register() { window.$workbox = register() .catch(error => {<% if (options.dev) { %> console.error('Error registering workbox:', error) <% } %>}) + +// Auto update application when something changes and update is available! +const workbox = await window.$workbox +if (workbox) { + workbox.addEventListener('installed', event => { + if (event.isUpdate) { + console.debug('There is an update for the PWA, reloading...') + window.location.reload() + } + }) +} + From e45dcc37f7795576885b904920ce3f9b13603284 Mon Sep 17 00:00:00 2001 From: Milad Hosseinpour Date: Sat, 28 Aug 2021 12:51:57 +0430 Subject: [PATCH 2/2] feat(workbox): add auto update to change the app content --- templates/workbox/workbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/workbox/workbox.js b/templates/workbox/workbox.js index fd71d5f2..1ba058c9 100755 --- a/templates/workbox/workbox.js +++ b/templates/workbox/workbox.js @@ -22,7 +22,7 @@ const workbox = await window.$workbox if (workbox) { workbox.addEventListener('installed', event => { if (event.isUpdate) { - console.debug('There is an update for the PWA, reloading...') + console.debug('There is an update for the PWA app, reloading...') window.location.reload() } })