moderate groupchat icons

This commit is contained in:
Samuel Newman
2026-05-26 12:05:21 +03:00
parent 4eb692cf87
commit 4382ae5f8d
7 changed files with 47 additions and 7 deletions
+19 -1
View File
@@ -1,4 +1,4 @@
import {useEffect} from 'react' import {useEffect, useMemo} from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import Animated, { import Animated, {
Easing, Easing,
@@ -8,6 +8,11 @@ import Animated, {
withDelay, withDelay,
withTiming, withTiming,
} from 'react-native-reanimated' } from 'react-native-reanimated'
import {
moderateProfile,
type ModerationOpts,
type ModerationUI,
} from '@atproto/api'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {UserAvatar} from '#/view/com/util/UserAvatar' import {UserAvatar} from '#/view/com/util/UserAvatar'
@@ -27,18 +32,27 @@ type Props = {
animate?: boolean animate?: boolean
profiles: bsky.profile.AnyProfileView[] profiles: bsky.profile.AnyProfileView[]
size?: number size?: number
moderationOpts?: ModerationOpts
} }
export function AvatarBubbles({ export function AvatarBubbles({
animate = false, animate = false,
profiles: allProfiles, profiles: allProfiles,
size = 120, size = 120,
moderationOpts,
}: Props) { }: Props) {
const {currentAccount} = useSession() const {currentAccount} = useSession()
const profiles = const profiles =
allProfiles.length > 2 allProfiles.length > 2
? allProfiles.filter(p => p.did !== currentAccount?.did) ? allProfiles.filter(p => p.did !== currentAccount?.did)
: allProfiles : allProfiles
const moderations = useMemo(() => {
if (!moderationOpts) return []
return profiles.map(p => {
return moderateProfile(p, moderationOpts)
})
}, [profiles, moderationOpts])
const scale = size / 120 const scale = size / 120
const marginOffset = size < 120 ? -2 : 0 const marginOffset = size < 120 ? -2 : 0
@@ -90,6 +104,7 @@ export function AvatarBubbles({
y={layout.y} y={layout.y}
zIndex={layout.zIndex} zIndex={layout.zIndex}
includeProfileBorder={layout.border} includeProfileBorder={layout.border}
moderation={moderations[i]?.ui('avatar')}
/> />
))} ))}
</View> </View>
@@ -105,6 +120,7 @@ function AvatarBubble({
y, y,
zIndex, zIndex,
includeProfileBorder, includeProfileBorder,
moderation,
}: { }: {
profile?: bsky.profile.AnyProfileView profile?: bsky.profile.AnyProfileView
scale: SharedValue<number> scale: SharedValue<number>
@@ -113,6 +129,7 @@ function AvatarBubble({
y: number y: number
zIndex?: number zIndex?: number
includeProfileBorder?: boolean includeProfileBorder?: boolean
moderation?: ModerationUI
}) { }) {
const t = useTheme() const t = useTheme()
@@ -140,6 +157,7 @@ function AvatarBubble({
type="user" type="user"
hideLiveBadge hideLiveBadge
noBorder noBorder
moderation={moderation}
/> />
) : ( ) : (
<AvatarPlaceholder size={size} /> <AvatarPlaceholder size={size} />
@@ -152,7 +152,11 @@ function RecentChatItem({
a.align_center, a.align_center,
]}> ]}>
{convo.kind === 'group' ? ( {convo.kind === 'group' ? (
<AvatarBubbles profiles={convo.members} size={WIDTH - 8} /> <AvatarBubbles
profiles={convo.members}
size={WIDTH - 8}
moderationOpts={moderationOpts}
/>
) : ( ) : (
<UserAvatar <UserAvatar
avatar={primaryProfile.avatar} avatar={primaryProfile.avatar}
@@ -514,7 +514,11 @@ function ExistingChatCard({
]}> ]}>
<ProfileCard.Header> <ProfileCard.Header>
{convo.kind === 'group' ? ( {convo.kind === 'group' ? (
<AvatarBubbles profiles={convo.members} size={40} /> <AvatarBubbles
profiles={convo.members}
size={40}
moderationOpts={moderationOpts}
/>
) : ( ) : (
<ProfileCard.Avatar <ProfileCard.Avatar
profile={convo.primaryMember} profile={convo.primaryMember}
+8 -2
View File
@@ -46,7 +46,7 @@ export function MessagesListHeader({convo}: {convo?: ConvoWithDetails | null}) {
convo.kind === 'direct' ? ( convo.kind === 'direct' ? (
<ProfileHeaderReady convo={convo} moderationOpts={moderationOpts} /> <ProfileHeaderReady convo={convo} moderationOpts={moderationOpts} />
) : ( ) : (
<GroupHeaderReady convo={convo} /> <GroupHeaderReady convo={convo} moderationOpts={moderationOpts} />
) )
) : ( ) : (
<> <>
@@ -152,8 +152,10 @@ function ProfileHeaderReady({
function GroupHeaderReady({ function GroupHeaderReady({
convo, convo,
moderationOpts,
}: { }: {
convo: Extract<ConvoWithDetails, {kind: 'group'}> convo: Extract<ConvoWithDetails, {kind: 'group'}>
moderationOpts: ModerationOpts
}) { }) {
const {t: l} = useLingui() const {t: l} = useLingui()
@@ -176,7 +178,11 @@ function GroupHeaderReady({
}, },
} }
}> }>
<AvatarBubbles size={40} profiles={convo.members} /> <AvatarBubbles
size={40}
profiles={convo.members}
moderationOpts={moderationOpts}
/>
<View style={[a.flex_row, a.flex_1, a.align_center]}> <View style={[a.flex_row, a.flex_1, a.align_center]}>
<Text <Text
style={[a.text_md, a.font_semi_bold, a.flex_shrink]} style={[a.text_md, a.font_semi_bold, a.flex_shrink]}
@@ -435,7 +435,10 @@ function SettingsHeader({
<View <View
style={[a.px_xl, a.py_4xl, a.border_b, t.atoms.border_contrast_low]}> style={[a.px_xl, a.py_4xl, a.border_b, t.atoms.border_contrast_low]}>
<View style={[a.align_center, a.justify_center]}> <View style={[a.align_center, a.justify_center]}>
<AvatarBubbles profiles={convo.members} /> <AvatarBubbles
profiles={convo.members}
moderationOpts={moderationOpts}
/>
</View> </View>
<Text <Text
style={[ style={[
@@ -204,6 +204,7 @@ function GroupChatItem({
<AvatarBubbles <AvatarBubbles
profiles={convo.members} profiles={convo.members}
size={isWithinSplitView ? 48 : 52} size={isWithinSplitView ? 48 : 52}
moderationOpts={moderationOpts}
/> />
} }
title={chatName} title={chatName}
@@ -88,7 +88,11 @@ export function MessagesListGroupInfoPanel({
return ( return (
<> <>
<View style={[a.align_center, a.justify_center]}> <View style={[a.align_center, a.justify_center]}>
<AvatarBubbles animate={true} profiles={convo.members} /> <AvatarBubbles
animate={true}
profiles={convo.members}
moderationOpts={moderationOpts}
/>
{convo.details.name ? ( {convo.details.name ? (
<Text <Text
style={[a.text_2xl, a.font_bold, a.mt_lg, a.px_lg, t.atoms.text]}> style={[a.text_2xl, a.font_bold, a.mt_lg, a.px_lg, t.atoms.text]}>