diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 32c1a65e2..f411235f3 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -36,6 +36,7 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j import { useInterfaceStore } from 'src/stores/interface.js' import { useLocalConfigStore } from 'src/stores/local_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useNotificationsStore } from 'src/stores/notifications.js' import { useOAuthStore } from 'src/stores/oauth.js' import { useStatusesStore } from 'src/stores/statuses.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' @@ -543,7 +544,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => { window.highlightConfig = useUserHighlightStore() FaviconService.initFaviconService() - initServiceWorker() + initServiceWorker(useNotificationsStore()) window.addEventListener('focus', () => updateFocus()) diff --git a/src/services/sw/sw.js b/src/services/sw/sw.js index 9040f0cf5..303297449 100644 --- a/src/services/sw/sw.js +++ b/src/services/sw/sw.js @@ -1,5 +1,3 @@ -import { useNotificationsStore } from 'src/stores/notifications.js' - /* global process */ function urlBase64ToUint8Array(base64String) { const padding = '='.repeat((4 - (base64String.length % 4)) % 4) @@ -96,7 +94,7 @@ function sendSubscriptionToBackEnd( return responseData }) } -export async function initServiceWorker() { +export async function initServiceWorker(notificationsStore) { if (!isSWSupported()) return await getOrCreateServiceWorker() navigator.serviceWorker.addEventListener('message', (event) => { @@ -104,7 +102,7 @@ export async function initServiceWorker() { switch (type) { case 'notificationClicked': - useNotificationsStore().notificationClicked(rest.id) + notificationsStore.notificationClicked(rest.id) } }) }