From e230f79b549b6324016f684f849f7793897befcb Mon Sep 17 00:00:00 2001 From: DecDuck Date: Sat, 22 Nov 2025 10:28:21 +1100 Subject: [PATCH] feat: delete all notifications --- components/NotificationItem.vue | 3 +- .../UserHeader/NotificationWidgetPanel.vue | 3 +- composables/notifications.ts | 5 +- i18n/locales/en_us.json | 1 + pages/account/notifications.vue | 72 +++++++++++-------- server/api/v1/notifications/clear.post.ts | 25 +++++++ 6 files changed, 76 insertions(+), 33 deletions(-) create mode 100644 server/api/v1/notifications/clear.post.ts diff --git a/components/NotificationItem.vue b/components/NotificationItem.vue index 243f4da..2606643 100644 --- a/components/NotificationItem.vue +++ b/components/NotificationItem.vue @@ -44,9 +44,10 @@ diff --git a/composables/notifications.ts b/composables/notifications.ts index ede125b..543ac77 100644 --- a/composables/notifications.ts +++ b/composables/notifications.ts @@ -1,12 +1,13 @@ +import type { SerializeObject } from "nitropack"; import type { NotificationModel } from "~/prisma/client/models"; const ws = new WebSocketHandler("/api/v1/notifications/ws"); export const useNotifications = () => - useState>("notifications", () => []); + useState>>("notifications", () => []); ws.listen((e) => { - const notification = JSON.parse(e) as NotificationModel; + const notification = JSON.parse(e) as SerializeObject; const notifications = useNotifications(); notifications.value.push(notification); }); diff --git a/i18n/locales/en_us.json b/i18n/locales/en_us.json index 02ff541..d167034 100644 --- a/i18n/locales/en_us.json +++ b/i18n/locales/en_us.json @@ -13,6 +13,7 @@ "all": "View all {arrow}", "desc": "View and manage your notifications.", "markAllAsRead": "Mark all as read", + "clear": "Clear notifications", "markAsRead": "Mark as read", "none": "No notifications", "notifications": "Notifications", diff --git a/pages/account/notifications.vue b/pages/account/notifications.vue index f625ab4..a1fd539 100644 --- a/pages/account/notifications.vue +++ b/pages/account/notifications.vue @@ -1,20 +1,33 @@