From 894ce3726a38733ea7b8c880658b962f92d021ae Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Nov 2022 20:26:04 +0100 Subject: [PATCH] Fix unnecessary service worker registration and preloading when logged out (#20341) --- app/javascript/mastodon/main.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/javascript/mastodon/main.js b/app/javascript/mastodon/main.js index d0337ce0cdc..f882217fbac 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'); - - try { - await wb.register(); - } catch (err) { - console.error(err); - - return; - } - if (me) { + const wb = new Workbox('/sw.js'); + + try { + await wb.register(); + } catch (err) { + console.error(err); + + return; + } + const registerPushNotifications = await import('mastodon/actions/push_notifications'); store.dispatch(registerPushNotifications.register());