From ac2398f1c51dc18234a015fafb2a08967ef48b9d Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Tue, 25 Mar 2025 16:11:47 +0330 Subject: [PATCH 1/5] fix font path --- frontend/assets/css/fonts/morabba.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/assets/css/fonts/morabba.css b/frontend/assets/css/fonts/morabba.css index d609e04..914f6ee 100644 --- a/frontend/assets/css/fonts/morabba.css +++ b/frontend/assets/css/fonts/morabba.css @@ -1,7 +1,7 @@ @layer base { @font-face { font-family: "Morabba"; - src: url("/fonts/Morabba/IRANYekanX-UltraLight.woff2"); + src: url("/fonts/Morabba/Morabba-UltraLight.woff2"); font-weight: 200; font-style: normal; font-display: swap; From 4930c5041fcfc5fce0d9eb2b694cf401a3e6c3dc Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Tue, 25 Mar 2025 16:27:37 +0330 Subject: [PATCH 2/5] test add use push notifiton ts --- .../api/notifications/usePushNotifications.ts | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 frontend/composables/api/notifications/usePushNotifications.ts diff --git a/frontend/composables/api/notifications/usePushNotifications.ts b/frontend/composables/api/notifications/usePushNotifications.ts new file mode 100644 index 0000000..efe355a --- /dev/null +++ b/frontend/composables/api/notifications/usePushNotifications.ts @@ -0,0 +1,65 @@ +// composables/usePushNotifications.ts +import { useLocalStorage, usePermission } from "@vueuse/core"; +import { onMounted, ref } from "vue"; +import useSubscribeNotification from "./useSubscribeNotification"; + +interface VapidKeys { + publicKey: string; +} + +export const usePushNotifications = () => { + 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(); + + // 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 swRegistration = await navigator.serviceWorker.ready; + + const applicationServerKey = vapid.value.publicKey + .replace(/-/g, "+") + .replace(/_/g, "/"); + + const convertedKey = Uint8Array.from(atob(applicationServerKey), (c) => + c.charCodeAt(0) + ); + + const pushSubscription = await swRegistration.pushManager.subscribe({ + userVisibleOnly: true, + applicationServerKey: convertedKey, + }); + + const subscriptionJson = pushSubscription.toJSON(); + + subscribeNotification({ + body: subscriptionJson, + }); + + subscription.value = subscriptionJson; + }; + + return { + isSupported, + permission, + subscribe, + subscription, + }; +}; From 34e9b39a7b745aa5d1e9957c2618367d6dcdbae4 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Tue, 25 Mar 2025 16:30:14 +0330 Subject: [PATCH 3/5] test2 fix notif --- frontend/pages/profile/notifications.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/pages/profile/notifications.vue b/frontend/pages/profile/notifications.vue index ce345bf..c0e9860 100644 --- a/frontend/pages/profile/notifications.vue +++ b/frontend/pages/profile/notifications.vue @@ -8,7 +8,7 @@ definePageMeta({ // imports -import { usePushNotifications } from "~/composables/global/usePushNotifications"; +import { usePushNotifications } from "~/composables/global/notifications/usePushNotifications"; import useSubscribeNotification from "~/composables/api/notifications/useSubscribeNotification"; // state From f1a5e1309e3030d3cafcd82d540dfa9a56b9ca12 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Tue, 25 Mar 2025 16:38:29 +0330 Subject: [PATCH 4/5] fix 3 notif --- frontend/pages/profile/notifications.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/pages/profile/notifications.vue b/frontend/pages/profile/notifications.vue index c0e9860..d4e57db 100644 --- a/frontend/pages/profile/notifications.vue +++ b/frontend/pages/profile/notifications.vue @@ -8,7 +8,7 @@ definePageMeta({ // imports -import { usePushNotifications } from "~/composables/global/notifications/usePushNotifications"; +import { usePushNotifications } from "~/composables/api/notifications/usePushNotifications"; import useSubscribeNotification from "~/composables/api/notifications/useSubscribeNotification"; // state From b9d41c1473165c845b5fbf331a583a4518c18afb Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Tue, 25 Mar 2025 16:50:18 +0330 Subject: [PATCH 5/5] relback changes to front --- .../api/notifications/usePushNotifications.ts | 65 ------------------- frontend/pages/profile/notifications.vue | 2 +- 2 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 frontend/composables/api/notifications/usePushNotifications.ts diff --git a/frontend/composables/api/notifications/usePushNotifications.ts b/frontend/composables/api/notifications/usePushNotifications.ts deleted file mode 100644 index efe355a..0000000 --- a/frontend/composables/api/notifications/usePushNotifications.ts +++ /dev/null @@ -1,65 +0,0 @@ -// composables/usePushNotifications.ts -import { useLocalStorage, usePermission } from "@vueuse/core"; -import { onMounted, ref } from "vue"; -import useSubscribeNotification from "./useSubscribeNotification"; - -interface VapidKeys { - publicKey: string; -} - -export const usePushNotifications = () => { - 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(); - - // 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 swRegistration = await navigator.serviceWorker.ready; - - const applicationServerKey = vapid.value.publicKey - .replace(/-/g, "+") - .replace(/_/g, "/"); - - const convertedKey = Uint8Array.from(atob(applicationServerKey), (c) => - c.charCodeAt(0) - ); - - const pushSubscription = await swRegistration.pushManager.subscribe({ - userVisibleOnly: true, - applicationServerKey: convertedKey, - }); - - const subscriptionJson = pushSubscription.toJSON(); - - subscribeNotification({ - body: subscriptionJson, - }); - - subscription.value = subscriptionJson; - }; - - return { - isSupported, - permission, - subscribe, - subscription, - }; -}; diff --git a/frontend/pages/profile/notifications.vue b/frontend/pages/profile/notifications.vue index d4e57db..025b6d0 100644 --- a/frontend/pages/profile/notifications.vue +++ b/frontend/pages/profile/notifications.vue @@ -8,7 +8,7 @@ definePageMeta({ // imports -import { usePushNotifications } from "~/composables/api/notifications/usePushNotifications"; +import { usePushNotifications } from "~/composables/global//usePushNotifications"; import useSubscribeNotification from "~/composables/api/notifications/useSubscribeNotification"; // state