about summary refs log tree commit diff
path: root/app/javascript/mastodon/service_worker/entry.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/mastodon/service_worker/entry.js')
-rw-r--r--app/javascript/mastodon/service_worker/entry.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/javascript/mastodon/service_worker/entry.js b/app/javascript/mastodon/service_worker/entry.js
index 364b67066..eea4cfc3c 100644
--- a/app/javascript/mastodon/service_worker/entry.js
+++ b/app/javascript/mastodon/service_worker/entry.js
@@ -1 +1,10 @@
 import './web_push_notifications';
+
+// Cause a new version of a registered Service Worker to replace an existing one
+// that is already installed, and replace the currently active worker on open pages.
+self.addEventListener('install', function(event) {
+  event.waitUntil(self.skipWaiting());
+});
+self.addEventListener('activate', function(event) {
+  event.waitUntil(self.clients.claim());
+});