From af68e1d395aa8b6d7c1f831fb622fc915e9bb408 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Wed, 26 Mar 2025 11:59:11 +0330 Subject: [PATCH] commented push notif file that i added (its a place holder file) --- .../global/usePushNotifications.ts | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/frontend/composables/global/usePushNotifications.ts b/frontend/composables/global/usePushNotifications.ts index d0b7a55..ce24fe0 100644 --- a/frontend/composables/global/usePushNotifications.ts +++ b/frontend/composables/global/usePushNotifications.ts @@ -8,58 +8,58 @@ interface VapidKeys { } export const usePushNotifications = () => { - const isSupported = ref(false); - const permission = usePermission("notifications"); - const subscription = useLocalStorage( - "push-subscription", - null - ); - const vapid = ref(null); + // const isSupported = ref(false); + // const permission = usePermission("notifications"); + // const subscription = useLocalStorage( + // "push-subscription", + // null + // ); + // const vapid = ref(null); - const { mutateAsync: subscribeNotification } = useSubscribeNotification(); - const toast = useToast(); + // const { mutateAsync: subscribeNotification } = useSubscribeNotification(); + // const toast = useToast(); - // Only run in client-side - onMounted(async () => { - if (typeof window !== "undefined" && "serviceWorker" in navigator) { - isSupported.value = true; - vapid.value = await $fetch("/api/vapid"); - } - }); + // // Only run in client-side + // onMounted(async () => { + // if (typeof window !== "undefined" && "serviceWorker" in navigator) { + // isSupported.value = true; + // vapid.value = await $fetch("/api/vapid"); + // } + // }); - const subscribe = async () => { - if (!isSupported.value || !vapid.value?.publicKey) { - throw new Error("Push notifications not supported"); - } + // const subscribe = async () => { + // if (!isSupported.value || !vapid.value?.publicKey) { + // throw new Error("Push notifications not supported"); + // } - const swRegistration = await navigator.serviceWorker.ready; + // const swRegistration = await navigator.serviceWorker.ready; - const applicationServerKey = vapid.value.publicKey - .replace(/-/g, "+") - .replace(/_/g, "/"); + // const applicationServerKey = vapid.value.publicKey + // .replace(/-/g, "+") + // .replace(/_/g, "/"); - const convertedKey = Uint8Array.from(atob(applicationServerKey), (c) => - c.charCodeAt(0) - ); + // const convertedKey = Uint8Array.from(atob(applicationServerKey), (c) => + // c.charCodeAt(0) + // ); - const pushSubscription = await swRegistration.pushManager.subscribe({ - userVisibleOnly: true, - applicationServerKey: convertedKey, - }); + // const pushSubscription = await swRegistration.pushManager.subscribe({ + // userVisibleOnly: true, + // applicationServerKey: convertedKey, + // }); - const subscriptionJson = pushSubscription.toJSON(); + // const subscriptionJson = pushSubscription.toJSON(); - subscribeNotification({ - body: subscriptionJson, - }); + // subscribeNotification({ + // body: subscriptionJson, + // }); - subscription.value = subscriptionJson; - }; + // subscription.value = subscriptionJson; + // }; - return { - isSupported, - permission, - subscribe, - subscription, - }; + // return { + // isSupported, + // permission, + // subscribe, + // subscription, + // }; };