diff --git a/src/localization/en.json b/src/localization/en.json index e1c58304..c73319d1 100644 --- a/src/localization/en.json +++ b/src/localization/en.json @@ -102,8 +102,8 @@ "tab_friend": "Friend", "tab_group": "Group", "tab_other": "Other", - "past_notifications": "Past", - "no_new_notifications": "No new notifications" + "past_notifications": "Last 24 hours", + "no_new_notifications": "No new notifications in the last 24 hours" } }, "view": { diff --git a/src/stores/notification.js b/src/stores/notification.js index b50c1bb2..903db2e4 100644 --- a/src/stores/notification.js +++ b/src/stores/notification.js @@ -134,6 +134,34 @@ export const useNotificationStore = defineStore('Notification', () => { const unseenOtherNotifications = computed(() => otherNotifications.value.filter((n) => unseenSet.value.has(n.id)) ); + const recentCutoff = computed(() => dayjs().subtract(24, 'hour').valueOf()); + function getNotificationTs(n) { + const raw = n.created_at ?? n.createdAt; + if (typeof raw === 'number') return raw > 1e12 ? raw : raw * 1000; + const ts = dayjs(raw).valueOf(); + return Number.isFinite(ts) ? ts : 0; + } + const recentFriendNotifications = computed(() => + friendNotifications.value.filter( + (n) => + !unseenSet.value.has(n.id) && + getNotificationTs(n) > recentCutoff.value + ) + ); + const recentGroupNotifications = computed(() => + groupNotifications.value.filter( + (n) => + !unseenSet.value.has(n.id) && + getNotificationTs(n) > recentCutoff.value + ) + ); + const recentOtherNotifications = computed(() => + otherNotifications.value.filter( + (n) => + !unseenSet.value.has(n.id) && + getNotificationTs(n) > recentCutoff.value + ) + ); const hasUnseenNotifications = computed( () => unseenNotifications.value.length > 0 ); @@ -2716,6 +2744,9 @@ export const useNotificationStore = defineStore('Notification', () => { unseenFriendNotifications, unseenGroupNotifications, unseenOtherNotifications, + recentFriendNotifications, + recentGroupNotifications, + recentOtherNotifications, hasUnseenNotifications, getNotificationCategory, isNotificationExpired, diff --git a/src/views/Sidebar/components/NotificationCenterSheet.vue b/src/views/Sidebar/components/NotificationCenterSheet.vue index f529daa1..e65fa617 100644 --- a/src/views/Sidebar/components/NotificationCenterSheet.vue +++ b/src/views/Sidebar/components/NotificationCenterSheet.vue @@ -30,6 +30,7 @@ @@ -37,6 +38,7 @@ @@ -44,6 +46,7 @@ @@ -78,8 +81,15 @@ const { refreshInviteMessageTableData } = useInviteStore(); const { clearInviteImageUpload } = useGalleryStore(); - const { isNotificationCenterOpen, unseenFriendNotifications, unseenGroupNotifications, unseenOtherNotifications } = - storeToRefs(useNotificationStore()); + const { + isNotificationCenterOpen, + unseenFriendNotifications, + unseenGroupNotifications, + unseenOtherNotifications, + recentFriendNotifications, + recentGroupNotifications, + recentOtherNotifications + } = storeToRefs(useNotificationStore()); const activeTab = ref('friend'); diff --git a/src/views/Sidebar/components/NotificationItem.vue b/src/views/Sidebar/components/NotificationItem.vue index 23c53f23..e9068ee2 100644 --- a/src/views/Sidebar/components/NotificationItem.vue +++ b/src/views/Sidebar/components/NotificationItem.vue @@ -9,7 +9,7 @@ - + {{ senderName }} {{ typeLabel }} @@ -19,16 +19,18 @@ class="ml-auto size-2 shrink-0 rounded-full bg-blue-500" /> - + {{ displayMessage }}
- - {{ relativeTime }} - + + + {{ relativeTime }} + +