Reuse moderateProfile to take advantage of the filter convenience getter

This commit is contained in:
Eric Bailey
2026-07-13 14:30:22 -05:00
parent e37e25ce59
commit 65589cb5d3
2 changed files with 37 additions and 24 deletions
+2
View File
@@ -1461,4 +1461,6 @@ export type Events = {
jobId?: string jobId?: string
elapsedInPhaseMs: number elapsedInPhaseMs: number
} }
'post:likedBy:click': {}
} }
+35 -24
View File
@@ -54,27 +54,33 @@ export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
const urip = new AtUri(post.uri) const urip = new AtUri(post.uri)
const likesHref = makeProfileLink(post.author, 'post', urip.rkey, 'liked-by') const likesHref = makeProfileLink(post.author, 'post', urip.rkey, 'liked-by')
const onPressLikedBy = () => ax.metric('post:likedBy:click', {})
const knownLikers = moderationOpts const knownLikersAndModeration = moderationOpts
? (data?.likes ?? []) ? (data?.likes ?? [])
.map(like => like.actor) .map(like => like.actor)
.filter( .map(actor => ({
actor => actor,
actor.did !== currentAccount?.did && moderation: moderateProfile(actor, moderationOpts),
actor.viewer?.following && }))
!actor.viewer.muted && .filter(({actor, moderation}) => {
!actor.viewer.blocking && const modui = moderation.ui('profileList')
!actor.viewer.blockedBy, const isMe = actor.did === currentAccount?.did
) const following = actor.viewer?.following
return !isMe && following && !modui.filter
})
: [] : []
const showKnownLikers = const showKnownLikers =
knownLikers.length > 0 && knownLikersAndModeration.length > 0 &&
ax.features.enabled(ax.features.PostThreadKnownLikersEnable) ax.features.enabled(ax.features.PostThreadKnownLikersEnable)
if (!showKnownLikers) { if (!showKnownLikers) {
return ( return (
<Link to={likesHref} label={l`Likes on this post`}> <Link
to={likesHref}
label={l`Likes on this post`}
onPress={onPressLikedBy}>
<Text <Text
testID="likeCount-expanded" testID="likeCount-expanded"
style={[a.text_md, t.atoms.text_contrast_medium]}> style={[a.text_md, t.atoms.text_contrast_medium]}>
@@ -89,17 +95,21 @@ export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
) )
} }
const names = knownLikers.slice(0, 2).map(actor => { const aviStackProfiles = knownLikersAndModeration
const moderation = moderateProfile(actor, moderationOpts!) .slice(0, 3)
return { .map(({actor}) => actor)
did: actor.did, const names = knownLikersAndModeration
href: makeProfileLink(actor), .slice(0, 2)
displayName: sanitizeDisplayName( .map(({actor, moderation}) => {
actor.displayName || actor.handle, return {
moderation.ui('displayName'), did: actor.did,
), href: makeProfileLink(actor),
} displayName: sanitizeDisplayName(
}) actor.displayName || actor.handle,
moderation.ui('displayName'),
),
}
})
const others = likeCount - names.length const others = likeCount - names.length
/* /*
@@ -151,8 +161,9 @@ export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
<Link <Link
to={likesHref} to={likesHref}
label={rowLabel} label={rowLabel}
style={[a.flex_row, a.align_center, a.gap_sm, a.flex_shrink]}> style={[a.flex_row, a.align_center, a.gap_sm, a.flex_shrink]}
<AvatarStack profiles={knownLikers.slice(0, 3)} size={AVI_SIZE} /> onPress={onPressLikedBy}>
<AvatarStack profiles={aviStackProfiles} size={AVI_SIZE} />
<Text <Text
testID="knownLikersStat" testID="knownLikersStat"
numberOfLines={1} numberOfLines={1}