feat: bluesky-style follow notification (#3151)

This commit is contained in:
TAKAHASHI Shuuji 2025-01-25 00:21:57 +09:00 committed by GitHub
parent 39b2182a00
commit a7d64fd132
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 55 additions and 20 deletions

View file

@ -5,7 +5,11 @@ const { items } = defineProps<{
items: GroupedNotifications items: GroupedNotifications
}>() }>()
const count = computed(() => items.items.length) const maxVisibleFollows = 5
const follows = computed(() => items.items)
const visibleFollows = computed(() => follows.value.slice(0, maxVisibleFollows))
const count = computed(() => follows.value.length)
const countPlus = computed(() => Math.max(count.value - maxVisibleFollows, 0))
const isExpanded = ref(false) 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
@ -17,16 +21,29 @@ const lang = computed(() => {
<div flex items-center top-0 left-2 pt-2 px-3> <div flex items-center top-0 left-2 pt-2 px-3>
<div :class="count > 1 ? 'i-ri-group-line' : 'i-ri-user-3-line'" me-3 color-blue text-xl aria-hidden="true" /> <div :class="count > 1 ? 'i-ri-group-line' : 'i-ri-user-3-line'" me-3 color-blue text-xl aria-hidden="true" />
<template v-if="count > 1"> <template v-if="count > 1">
<CommonLocalizedNumber <AccountHoverWrapper
keypath="notification.followed_you_count" :account="follows[0].account"
:count="count" >
<NuxtLink :to="getAccountRoute(follows[0].account)">
<AccountDisplayName
:account="follows[0].account"
text-primary font-bold line-clamp-1 ws-pre-wrap break-all hover:underline
/> />
</NuxtLink>
</AccountHoverWrapper>
&nbsp;{{ $t('notification.and') }}&nbsp;
<CommonLocalizedNumber
keypath="notification.others"
:count="count - 1"
text-primary font-bold line-clamp-1 ws-pre-wrap break-all
/>
&nbsp;{{ $t('notification.followed_you') }}
</template> </template>
<template v-else-if="count === 1"> <template v-else-if="count === 1">
<NuxtLink :to="getAccountRoute(items.items[0].account)"> <NuxtLink :to="getAccountRoute(follows[0].account)">
<AccountDisplayName <AccountDisplayName
:account="items.items[0].account" :account="follows[0].account"
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 hover:underline
/> />
</NuxtLink> </NuxtLink>
<span me-1 ws-nowrap> <span me-1 ws-nowrap>
@ -35,22 +52,38 @@ const lang = computed(() => {
</template> </template>
</div> </div>
<div pb-2 ps8> <div pb-2 ps8>
<div v-if="isExpanded"> <div
<AccountCard v-if="!isExpanded && count > 1"
v-for="item in items.items" flex="~ wrap gap-1.75" p4 items-center cursor-pointer
:key="item.id" @click="isExpanded = !isExpanded"
:account="item.account"
p3
/>
</div>
<div v-else flex="~ wrap gap-1.75" p4>
<AccountHoverWrapper
v-for="item in items.items"
:key="item.id"
:account="item.account"
> >
<NuxtLink :to="getAccountRoute(item.account)"> <AccountHoverWrapper
<AccountAvatar :account="item.account" w-12 h-12 /> v-for="follow in visibleFollows"
:key="follow.id"
:account="follow.account"
>
<NuxtLink :to="getAccountRoute(follow.account)">
<AccountAvatar :account="follow.account" w-12 h-12 />
</NuxtLink>
</AccountHoverWrapper>
<div flex="~ 1" items-center>
<span v-if="countPlus > 0" ps-2 text="base lg">+{{ countPlus }}</span>
<div i-ri:arrow-down-s-line mx-1 text-secondary text-xl aria-hidden="true" />
</div>
</div>
<div v-else>
<div v-if="count > 1" flex p-4 pb-2 cursor-pointer @click="isExpanded = !isExpanded">
<div i-ri:arrow-up-s-line ms-2 text-secondary text-xl aria-hidden="true" />
<span ps-2 text-base>Hide</span>
</div>
<AccountHoverWrapper
v-for="follow in follows"
:key="follow.id"
:account="follow.account"
>
<NuxtLink :to="getAccountRoute(follow.account)" flex gap-4 px-4 py-2>
<AccountAvatar :account="follow.account" w-12 h-12 />
<StatusAccountDetails :account="follow.account" />
</NuxtLink> </NuxtLink>
</AccountHoverWrapper> </AccountHoverWrapper>
</div> </div>

View file

@ -334,10 +334,12 @@
"zen_mode": "Zen Mode" "zen_mode": "Zen Mode"
}, },
"notification": { "notification": {
"and": "and",
"favourited_post": "favorited your post", "favourited_post": "favorited your post",
"followed_you": "followed you", "followed_you": "followed you",
"followed_you_count": "{0} people followed you|{0} person followed you|{0} people followed you", "followed_you_count": "{0} people followed you|{0} person followed you|{0} people followed you",
"missing_type": "MISSING notification.type:", "missing_type": "MISSING notification.type:",
"others": "{0} others|{0} other|{0} others",
"reblogged_post": "boosted your post", "reblogged_post": "boosted your post",
"reported": "{0} reported {1}", "reported": "{0} reported {1}",
"request_to_follow": "requested to follow you", "request_to_follow": "requested to follow you",