ServiceWorker: skipWaiting and reload tabs when new ServiceWorker is ready

This commit is contained in:
Alex Gleason 2022-05-31 20:46:40 -05:00
parent 66399f754e
commit 174496c71d
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 10 additions and 1 deletions

View file

@ -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()');
});

View file

@ -85,6 +85,7 @@ module.exports = merge(sharedConfig, {
ServiceWorker: {
cacheName: 'soapbox',
entry: join(__dirname, '../app/soapbox/service_worker/entry.ts'),
events: true,
minify: true,
},
cacheMaps: [{