This commit is contained in:
Minseo Lee
2024-07-26 13:50:15 +09:00
parent 149b30ae75
commit 11ef3647de
+59 -3
View File
@@ -18,7 +18,7 @@ import {
ModerationOpts, ModerationOpts,
} from '@atproto/api' } from '@atproto/api'
import {AtUri} from '@atproto/api' import {AtUri} from '@atproto/api'
import {msg, Plural, Trans} from '@lingui/macro' import {msg, Plural, plural, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useNavigation} from '@react-navigation/native' import {useNavigation} from '@react-navigation/native'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
@@ -175,6 +175,7 @@ let FeedItem = ({
) )
const niceTimestamp = niceDate(item.notification.indexedAt) const niceTimestamp = niceDate(item.notification.indexedAt)
let a11yAuthor = firstAuthorName
let author = ( let author = (
<TextLink <TextLink
key={authors[0].href} key={authors[0].href}
@@ -185,6 +186,7 @@ let FeedItem = ({
/> />
) )
let a11yLabel = ''
let action: ReactElement let action: ReactElement
let icon = ( let icon = (
<HeartIconFilled <HeartIconFilled
@@ -197,6 +199,15 @@ let FeedItem = ({
) )
if (item.type === 'post-like') { if (item.type === 'post-like') {
a11yLabel =
authors.length > 1
? _(
msg`${a11yAuthor} and ${plural(authors.length - 1, {
one: `${formattedCount} other`,
other: `${formattedCount} others`,
})} liked your post · ${niceTimestamp}`,
)
: _(msg`${a11yAuthor} liked your post · ${niceTimestamp}`)
action = action =
authors.length > 1 ? ( authors.length > 1 ? (
<Trans> <Trans>
@@ -214,6 +225,15 @@ let FeedItem = ({
<Trans>{author} liked your post</Trans> <Trans>{author} liked your post</Trans>
) )
} else if (item.type === 'repost') { } else if (item.type === 'repost') {
a11yLabel =
authors.length > 1
? _(
msg`${a11yAuthor} and ${plural(authors.length - 1, {
one: `${formattedCount} other`,
other: `${formattedCount} others`,
})} reposted your post · ${niceTimestamp}`,
)
: _(msg`${a11yAuthor} reposted your post · ${niceTimestamp}`)
action = action =
authors.length > 1 ? ( authors.length > 1 ? (
<Trans> <Trans>
@@ -236,6 +256,15 @@ let FeedItem = ({
item.notification.author.viewer?.following && item.notification.author.viewer?.following &&
gate('ungroup_follow_backs') gate('ungroup_follow_backs')
) { ) {
a11yLabel =
authors.length > 1
? _(
msg`${a11yAuthor} and ${plural(authors.length - 1, {
one: `${formattedCount} other`,
other: `${formattedCount} others`,
})} followed you back · ${niceTimestamp}`,
)
: _(msg`${a11yAuthor} followed you back · ${niceTimestamp}`)
action = action =
authors.length > 1 ? ( authors.length > 1 ? (
<Trans> <Trans>
@@ -253,6 +282,15 @@ let FeedItem = ({
<Trans>{author} followed you back</Trans> <Trans>{author} followed you back</Trans>
) )
} else { } else {
a11yLabel =
authors.length > 1
? _(
msg`${a11yAuthor} and ${plural(authors.length - 1, {
one: `${formattedCount} other`,
other: `${formattedCount} others`,
})} followed you · ${niceTimestamp}`,
)
: _(msg`${a11yAuthor} followed you · ${niceTimestamp}`)
action = action =
authors.length > 1 ? ( authors.length > 1 ? (
<Trans> <Trans>
@@ -272,6 +310,15 @@ let FeedItem = ({
} }
icon = <PersonPlusIcon size="xl" style={{color: t.palette.primary_500}} /> icon = <PersonPlusIcon size="xl" style={{color: t.palette.primary_500}} />
} else if (item.type === 'feedgen-like') { } else if (item.type === 'feedgen-like') {
a11yLabel =
authors.length > 1
? _(
msg`${a11yAuthor} and ${plural(authors.length - 1, {
one: `${formattedCount} other`,
other: `${formattedCount} others`,
})} liked your custom feed · ${niceTimestamp}`,
)
: _(msg`${a11yAuthor} liked your custom feed · ${niceTimestamp}`)
action = action =
authors.length > 1 ? ( authors.length > 1 ? (
<Trans> <Trans>
@@ -289,6 +336,17 @@ let FeedItem = ({
<Trans>{author} liked your custom feed</Trans> <Trans>{author} liked your custom feed</Trans>
) )
} else if (item.type === 'starterpack-joined') { } else if (item.type === 'starterpack-joined') {
a11yLabel =
authors.length > 1
? _(
msg`${a11yAuthor} and ${plural(authors.length - 1, {
one: `${formattedCount} other`,
other: `${formattedCount} others`,
})} signed up with your starter pack · ${niceTimestamp}`,
)
: _(
msg`${a11yAuthor} signed up with your starter pack · ${niceTimestamp}`,
)
action = action =
authors.length > 1 ? ( authors.length > 1 ? (
<Trans> <Trans>
@@ -314,8 +372,6 @@ let FeedItem = ({
return null return null
} }
const a11yLabel = `${action} ${niceTimestamp}`
return ( return (
<Link <Link
testID={`feedItem-by-${item.notification.author.handle}`} testID={`feedItem-by-${item.notification.author.handle}`}