Skip to content

Commit

Permalink
feat: bluesky-style follow notification (#3151)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuuji3 authored Jan 24, 2025
1 parent 39b2182 commit a7d64fd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 19 deletions.
71 changes: 52 additions & 19 deletions components/notification/NotificationGroupedFollow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ const { items } = defineProps<{
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 lang = computed(() => {
return (count.value > 1 || count.value === 0) ? undefined : items.items[0].status?.language
Expand All @@ -17,16 +21,29 @@ const lang = computed(() => {
<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" />
<template v-if="count > 1">
<AccountHoverWrapper
:account="follows[0].account"
>
<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.followed_you_count"
:count="count"
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 v-else-if="count === 1">
<NuxtLink :to="getAccountRoute(items.items[0].account)">
<NuxtLink :to="getAccountRoute(follows[0].account)">
<AccountDisplayName
:account="items.items[0].account"
text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all
:account="follows[0].account"
text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all hover:underline
/>
</NuxtLink>
<span me-1 ws-nowrap>
Expand All @@ -35,22 +52,38 @@ const lang = computed(() => {
</template>
</div>
<div pb-2 ps8>
<div v-if="isExpanded">
<AccountCard
v-for="item in items.items"
:key="item.id"
:account="item.account"
p3
/>
<div
v-if="!isExpanded && count > 1"
flex="~ wrap gap-1.75" p4 items-center cursor-pointer
@click="isExpanded = !isExpanded"
>
<AccountHoverWrapper
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 flex="~ wrap gap-1.75" p4>
<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="item in items.items"
:key="item.id"
:account="item.account"
v-for="follow in follows"
:key="follow.id"
:account="follow.account"
>
<NuxtLink :to="getAccountRoute(item.account)">
<AccountAvatar :account="item.account" w-12 h-12 />
<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>
</AccountHoverWrapper>
</div>
Expand Down
2 changes: 2 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,12 @@
"zen_mode": "Zen Mode"
},
"notification": {
"and": "and",
"favourited_post": "favorited your post",
"followed_you": "followed you",
"followed_you_count": "{0} people followed you|{0} person followed you|{0} people followed you",
"missing_type": "MISSING notification.type:",
"others": "{0} others|{0} other|{0} others",
"reblogged_post": "boosted your post",
"reported": "{0} reported {1}",
"request_to_follow": "requested to follow you",
Expand Down

0 comments on commit a7d64fd

Please sign in to comment.