feat: show notification timestamp (#3215)

This commit is contained in:
TAKAHASHI Shuuji 2025-03-03 01:54:35 +09:00 committed by GitHub
parent 41379627b5
commit d94b14ae53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 8 deletions

View file

@ -33,6 +33,9 @@ const unsupportedEmojiReactionTypes = ['pleroma:emoji_reaction', 'reaction']
if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotificationTypes.includes(notification.type)) { if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotificationTypes.includes(notification.type)) {
console.warn(`[DEV] ${t('notification.missing_type')} '${notification.type}' (notification.id: ${notification.id})`) console.warn(`[DEV] ${t('notification.missing_type')} '${notification.type}' (notification.id: ${notification.id})`)
} }
const timeAgoOptions = useTimeAgoOptions(true)
const timeAgo = useTimeAgo(() => notification.createdAt, timeAgoOptions)
</script> </script>
<template> <template>
@ -48,7 +51,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
<div i-ri-user-3-line text-xl me-3 color-blue /> <div i-ri-user-3-line text-xl me-3 color-blue />
<AccountDisplayName :account="notification.account" text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all /> <AccountDisplayName :account="notification.account" text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all />
<span ws-nowrap> <span ws-nowrap>
{{ $t('notification.followed_you') }} {{ $t('notification.followed_you') }}{{ timeAgo }}
</span> </span>
</div> </div>
<AccountBigCard <AccountBigCard
@ -65,7 +68,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
:account="notification.account" :account="notification.account"
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
/> />
<span>{{ $t("notification.signed_up") }}</span> <span>{{ $t("notification.signed_up") }}{{ timeAgo }}</span>
</div> </div>
</NuxtLink> </NuxtLink>
</template> </template>
@ -94,7 +97,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all
/> />
<span me-1 ws-nowrap> <span me-1 ws-nowrap>
{{ $t('notification.request_to_follow') }} {{ $t('notification.request_to_follow') }}{{ timeAgo }}
</span> </span>
</div> </div>
<AccountCard p="s-2 e-4 b-2" hover-card :account="notification.account"> <AccountCard p="s-2 e-4 b-2" hover-card :account="notification.account">
@ -108,7 +111,7 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
<div i-ri:edit-2-fill text-xl me-1 text-secondary /> <div i-ri:edit-2-fill text-xl me-1 text-secondary />
<AccountInlineInfo :account="notification.account" me1 /> <AccountInlineInfo :account="notification.account" me1 />
<span ws-nowrap> <span ws-nowrap>
{{ $t('notification.update_status') }} {{ $t('notification.update_status') }}{{ timeAgo }}
</span> </span>
</div> </div>
</template> </template>

View file

@ -14,6 +14,9 @@ const isExpanded = ref(false)
const lang = computed(() => { const lang = computed(() => {
return (count.value > 1 || count.value === 0) ? undefined : items.items[0].status?.language return (count.value > 1 || count.value === 0) ? undefined : items.items[0].status?.language
}) })
const timeAgoOptions = useTimeAgoOptions(true)
const timeAgo = useTimeAgo(() => follows.value[0].createdAt, timeAgoOptions)
</script> </script>
<template> <template>
@ -37,7 +40,7 @@ const lang = computed(() => {
:count="count - 1" :count="count - 1"
text-primary font-bold line-clamp-1 ws-pre-wrap break-all text-primary font-bold line-clamp-1 ws-pre-wrap break-all
/> />
&nbsp;{{ $t('notification.followed_you') }} &nbsp;{{ $t('notification.followed_you') }}{{ timeAgo }}
</template> </template>
<template v-else-if="count === 1"> <template v-else-if="count === 1">
<NuxtLink :to="getAccountRoute(follows[0].account)"> <NuxtLink :to="getAccountRoute(follows[0].account)">
@ -47,7 +50,7 @@ const lang = computed(() => {
/> />
</NuxtLink> </NuxtLink>
<span me-1 ws-nowrap> <span me-1 ws-nowrap>
{{ $t('notification.followed_you') }} {{ $t('notification.followed_you') }}{{ timeAgo }}
</span> </span>
</template> </template>
</div> </div>

View file

@ -8,6 +8,10 @@ const useStarFavoriteIcon = usePreferences('useStarFavoriteIcon')
const reblogs = computed(() => group.likes.filter(i => i.reblog)) const reblogs = computed(() => group.likes.filter(i => i.reblog))
const likes = computed(() => group.likes.filter(i => i.favourite && !i.reblog)) const likes = computed(() => group.likes.filter(i => i.favourite && !i.reblog))
const timeAgoOptions = useTimeAgoOptions(true)
const reblogsTimeAgo = useTimeAgo(() => reblogs.value[0].reblog?.createdAt ?? '', timeAgoOptions)
const likesTimeAgo = useTimeAgo(() => likes.value[0].favourite?.createdAt ?? '', timeAgoOptions)
</script> </script>
<template> <template>
@ -24,7 +28,7 @@ const likes = computed(() => group.likes.filter(i => i.favourite && !i.reblog))
</AccountHoverWrapper> </AccountHoverWrapper>
</template> </template>
<div ml1> <div ml1>
{{ $t('notification.reblogged_post') }} {{ $t('notification.reblogged_post') }}{{ reblogsTimeAgo }}
</div> </div>
</div> </div>
<div v-if="likes.length" flex="~ gap-1 wrap"> <div v-if="likes.length" flex="~ gap-1 wrap">
@ -37,7 +41,7 @@ const likes = computed(() => group.likes.filter(i => i.favourite && !i.reblog))
</AccountHoverWrapper> </AccountHoverWrapper>
</template> </template>
<div ms-4> <div ms-4>
{{ $t('notification.favourited_post') }} {{ $t('notification.favourited_post') }} {{ likesTimeAgo }}
</div> </div>
</div> </div>
</div> </div>