From 3d3ba53a53fbcd1e79b65537fc78dc507aa79498 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Mon, 10 Mar 2025 14:39:24 +0700 Subject: [PATCH] fix: mark notifications as read when accessed --- src/layouts/MainLayout.vue | 129 ++++++++++++++----------- src/pages/00_notification/MainPage.vue | 9 +- 2 files changed, 78 insertions(+), 60 deletions(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index a83837ee..15f3da8f 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -115,8 +115,13 @@ function doLogout() { } function readNoti(id: string) { + const notification = notificationData.value.find((n) => n.id === id); + state.notiDialog = true; state.notiId = id; + if (notification) { + notification.read = true; + } } onMounted(async () => { @@ -301,20 +306,19 @@ onMounted(async () => { :offset="[0, 10]" anchor="bottom middle" self="top middle" - style="max-height: 30vh; width: 300px" @before-hide=" () => { state.notiOpen = false; } " > -
+
{{ $t('noti.title') }}
-
+
{ @click="setActive(btn)" />
-
-
+ - + - - - + + -
- - {{ item.title }} - - - {{ item.detail }} - -
- - {{ moment(item.createdAt).fromNow() }} - - +
+ {{ item.title }} + + {{ item.detail }} - - -
-
- - {{ $t('general.noData') }} + +
+ + {{ moment(item.createdAt).fromNow() }} - -
+ + {{ item.title }} + {{ item.detail }} + + + +
+ + {{ $t('general.noData') }} + +
n.id === id); + state.notiId = id; state.notiDialog = true; + if (notification) { + notification.read = true; + } } onMounted(async () => { @@ -203,10 +208,10 @@ onMounted(async () => { class="q-py-sm q-px-md rounded row no-wrap items-center" @click.stop="readNoti(n.id)" > - + />