From 174496c71d14bb77486de37c64e35c5eb1b8fa8d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 31 May 2022 20:46:40 -0500 Subject: [PATCH] ServiceWorker: skipWaiting and reload tabs when new ServiceWorker is ready --- app/soapbox/main.tsx | 10 +++++++++- webpack/production.js | Bin 3818 -> 3840 bytes 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/soapbox/main.tsx b/app/soapbox/main.tsx index 9505ae07ad..9347d796c1 100644 --- a/app/soapbox/main.tsx +++ b/app/soapbox/main.tsx @@ -31,7 +31,15 @@ function main() { if (BuildConfig.NODE_ENV === 'production') { // avoid offline in dev mode because it's harder to debug - OfflinePluginRuntime.install(); + // https://github.com/NekR/offline-plugin/pull/201#issuecomment-285133572 + OfflinePluginRuntime.install({ + onUpdateReady: function() { + OfflinePluginRuntime.applyUpdate(); + }, + onUpdated: function() { + window.location.reload(); + }, + }); } perf.stop('main()'); }); diff --git a/webpack/production.js b/webpack/production.js index 18666a109926c69a907088cfe1539219b7800957..c90decd4e14a0df6964c22abf5f3e80074fc3bbb 100644 GIT binary patch delta 25 gcmaDQ+aR|ghnpw0EH$sB*h-