about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-10 20:26:04 +0100
committerGitHub <noreply@github.com>2022-11-10 20:26:04 +0100
commit894ce3726a38733ea7b8c880658b962f92d021ae (patch)
treeaaf8ed8ee3e55559bdc3ba99520c03769050efc1 /app
parent397845453ec8ab592ffe51657cbd80c57f69c597 (diff)
Fix unnecessary service worker registration and preloading when logged out (#20341)
Diffstat (limited to 'app')
-rw-r--r--app/javascript/mastodon/main.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/javascript/mastodon/main.js b/app/javascript/mastodon/main.js
index d0337ce0c..f882217fb 100644
--- a/app/javascript/mastodon/main.js
+++ b/app/javascript/mastodon/main.js
@@ -25,17 +25,17 @@ function main() {
         import('mastodon/initial_state'),
       ]);
 
-      const wb = new Workbox('/sw.js');
+      if (me) {
+        const wb = new Workbox('/sw.js');
 
-      try {
-        await wb.register();
-      } catch (err) {
-        console.error(err);
+        try {
+          await wb.register();
+        } catch (err) {
+          console.error(err);
 
-        return;
-      }
+          return;
+        }
 
-      if (me) {
         const registerPushNotifications = await import('mastodon/actions/push_notifications');
 
         store.dispatch(registerPushNotifications.register());