Skip to content

Commit d94b14a

Browse files
authored
feat: show notification timestamp (#3215)
1 parent 4137962 commit d94b14a

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

components/notification/NotificationCard.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const unsupportedEmojiReactionTypes = ['pleroma:emoji_reaction', 'reaction']
3333
if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotificationTypes.includes(notification.type)) {
3434
console.warn(`[DEV] ${t('notification.missing_type')} '${notification.type}' (notification.id: ${notification.id})`)
3535
}
36+
37+
const timeAgoOptions = useTimeAgoOptions(true)
38+
const timeAgo = useTimeAgo(() => notification.createdAt, timeAgoOptions)
3639
</script>
3740

3841
<template>
@@ -48,7 +51,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
4851
<div i-ri-user-3-line text-xl me-3 color-blue />
4952
<AccountDisplayName :account="notification.account" text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all />
5053
<span ws-nowrap>
51-
{{ $t('notification.followed_you') }}
54+
{{ $t('notification.followed_you') }}・{{ timeAgo }}
5255
</span>
5356
</div>
5457
<AccountBigCard
@@ -65,7 +68,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
6568
:account="notification.account"
6669
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
6770
/>
68-
<span>{{ $t("notification.signed_up") }}</span>
71+
<span>{{ $t("notification.signed_up") }}・{{ timeAgo }}</span>
6972
</div>
7073
</NuxtLink>
7174
</template>
@@ -94,7 +97,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
9497
text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all
9598
/>
9699
<span me-1 ws-nowrap>
97-
{{ $t('notification.request_to_follow') }}
100+
{{ $t('notification.request_to_follow') }}・{{ timeAgo }}
98101
</span>
99102
</div>
100103
<AccountCard p="s-2 e-4 b-2" hover-card :account="notification.account">
@@ -108,7 +111,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
108111
<div i-ri:edit-2-fill text-xl me-1 text-secondary />
109112
<AccountInlineInfo :account="notification.account" me1 />
110113
<span ws-nowrap>
111-
{{ $t('notification.update_status') }}
114+
{{ $t('notification.update_status') }}・{{ timeAgo }}
112115
</span>
113116
</div>
114117
</template>

components/notification/NotificationGroupedFollow.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const isExpanded = ref(false)
1414
const lang = computed(() => {
1515
return (count.value > 1 || count.value === 0) ? undefined : items.items[0].status?.language
1616
})
17+
18+
const timeAgoOptions = useTimeAgoOptions(true)
19+
const timeAgo = useTimeAgo(() => follows.value[0].createdAt, timeAgoOptions)
1720
</script>
1821

1922
<template>
@@ -37,7 +40,7 @@ const lang = computed(() => {
3740
:count="count - 1"
3841
text-primary font-bold line-clamp-1 ws-pre-wrap break-all
3942
/>
40-
&nbsp;{{ $t('notification.followed_you') }}
43+
&nbsp;{{ $t('notification.followed_you') }}・{{ timeAgo }}
4144
</template>
4245
<template v-else-if="count === 1">
4346
<NuxtLink :to="getAccountRoute(follows[0].account)">
@@ -47,7 +50,7 @@ const lang = computed(() => {
4750
/>
4851
</NuxtLink>
4952
<span me-1 ws-nowrap>
50-
{{ $t('notification.followed_you') }}
53+
{{ $t('notification.followed_you') }}・{{ timeAgo }}
5154
</span>
5255
</template>
5356
</div>

components/notification/NotificationGroupedLikes.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const useStarFavoriteIcon = usePreferences('useStarFavoriteIcon')
88
99
const reblogs = computed(() => group.likes.filter(i => i.reblog))
1010
const likes = computed(() => group.likes.filter(i => i.favourite && !i.reblog))
11+
12+
const timeAgoOptions = useTimeAgoOptions(true)
13+
const reblogsTimeAgo = useTimeAgo(() => reblogs.value[0].reblog?.createdAt ?? '', timeAgoOptions)
14+
const likesTimeAgo = useTimeAgo(() => likes.value[0].favourite?.createdAt ?? '', timeAgoOptions)
1115
</script>
1216

1317
<template>
@@ -24,7 +28,7 @@ const likes = computed(() => group.likes.filter(i => i.favourite && !i.reblog))
2428
</AccountHoverWrapper>
2529
</template>
2630
<div ml1>
27-
{{ $t('notification.reblogged_post') }}
31+
{{ $t('notification.reblogged_post') }}・{{ reblogsTimeAgo }}
2832
</div>
2933
</div>
3034
<div v-if="likes.length" flex="~ gap-1 wrap">
@@ -37,7 +41,7 @@ const likes = computed(() => group.likes.filter(i => i.favourite && !i.reblog))
3741
</AccountHoverWrapper>
3842
</template>
3943
<div ms-4>
40-
{{ $t('notification.favourited_post') }}
44+
{{ $t('notification.favourited_post') }} ・{{ likesTimeAgo }}
4145
</div>
4246
</div>
4347
</div>

0 commit comments

Comments
 (0)