Add count to anchor
This commit is contained in:
@@ -415,13 +415,18 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
||||
/>
|
||||
{post.repostCount !== 0 ||
|
||||
post.likeCount !== 0 ||
|
||||
post.quoteCount !== 0 ? (
|
||||
post.quoteCount !== 0 ||
|
||||
post.bookmarkCount !== 0 ? (
|
||||
// Show this section unless we're *sure* it has no engagement.
|
||||
<View
|
||||
style={[
|
||||
a.flex_row,
|
||||
a.flex_wrap,
|
||||
a.align_center,
|
||||
a.gap_lg,
|
||||
{
|
||||
rowGap: a.gap_sm.gap,
|
||||
columnGap: a.gap_lg.gap,
|
||||
},
|
||||
a.border_t,
|
||||
a.border_b,
|
||||
a.mt_md,
|
||||
@@ -474,6 +479,22 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
||||
</Text>
|
||||
</Link>
|
||||
) : null}
|
||||
{post.bookmarkCount != null && post.bookmarkCount !== 0 ? (
|
||||
<Link to={likesHref} label={_(msg`Saves of this post`)}>
|
||||
<Text
|
||||
testID="bookmarkCount-expanded"
|
||||
style={[a.text_md, t.atoms.text_contrast_medium]}>
|
||||
<Text style={[a.text_md, a.font_bold, t.atoms.text]}>
|
||||
{formatPostStatCount(i18n, post.bookmarkCount)}
|
||||
</Text>{' '}
|
||||
<Plural
|
||||
value={post.bookmarkCount}
|
||||
one="save"
|
||||
other="saves"
|
||||
/>
|
||||
</Text>
|
||||
</Link>
|
||||
) : null}
|
||||
</View>
|
||||
) : null}
|
||||
<View
|
||||
|
||||
Vendored
+13
@@ -93,6 +93,18 @@ function mergeShadow(
|
||||
likeCount = Math.max(0, likeCount)
|
||||
}
|
||||
|
||||
let bookmarkCount = post.bookmarkCount ?? 0
|
||||
if ('bookmarked' in shadow) {
|
||||
const wasBookmarked = !!post.viewer?.bookmarked
|
||||
const isBookmarked = !!shadow.bookmarked
|
||||
if (wasBookmarked && !isBookmarked) {
|
||||
bookmarkCount--
|
||||
} else if (!wasBookmarked && isBookmarked) {
|
||||
bookmarkCount++
|
||||
}
|
||||
bookmarkCount = Math.max(0, bookmarkCount)
|
||||
}
|
||||
|
||||
let repostCount = post.repostCount ?? 0
|
||||
if ('repostUri' in shadow) {
|
||||
const wasReposted = !!post.viewer?.repost
|
||||
@@ -128,6 +140,7 @@ function mergeShadow(
|
||||
likeCount: likeCount,
|
||||
repostCount: repostCount,
|
||||
replyCount: replyCount,
|
||||
bookmarkCount: bookmarkCount,
|
||||
viewer: {
|
||||
...(post.viewer || {}),
|
||||
like: 'likeUri' in shadow ? shadow.likeUri : post.viewer?.like,
|
||||
|
||||
Reference in New Issue
Block a user