[Chat] Fix assumption that every chat has an owner (#10373)

This commit is contained in:
Samuel Newman
2026-05-06 14:11:07 +01:00
committed by GitHub
parent 2aa544fade
commit a7ed3ee3cc
12 changed files with 163 additions and 90 deletions
@@ -1,5 +1,9 @@
import {ScrollView, View} from 'react-native'
import {moderateProfile, type ModerationOpts} from '@atproto/api'
import {
type ChatBskyActorDefs,
moderateProfile,
type ModerationOpts,
} from '@atproto/api'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
@@ -66,8 +70,8 @@ export function RecentChats({
if (!convo) return null
if (
(convo.kind === 'direct' &&
convo.primaryMember.handle === 'missing.invalid') ||
!convo.primaryMember ||
convo.primaryMember.handle === 'missing.invalid' ||
convo.view.muted
) {
return null
@@ -77,6 +81,7 @@ export function RecentChats({
<RecentChatItem
key={convo.view.id}
convo={convo}
primaryMember={convo.primaryMember}
onPress={() => onSelectChat(convo.view.id)}
moderationOpts={moderationOpts}
/>
@@ -103,15 +108,17 @@ function RecentChatItem({
onPress,
moderationOpts,
convo,
primaryMember,
}: {
onPress: () => void
moderationOpts: ModerationOpts
convo: ConvoWithDetails
primaryMember: ChatBskyActorDefs.ProfileViewBasic
}) {
const {_} = useLingui()
const t = useTheme()
const primaryProfile = useProfileShadow(convo.primaryMember)
const primaryProfile = useProfileShadow(primaryMember)
const moderation = moderateProfile(primaryProfile, moderationOpts)
const name =
@@ -479,14 +479,15 @@ function ExistingChatCard({
const {t: l} = useLingui()
const enabled =
convo.kind === 'group' ? convo.details.lockStatus === 'unlocked' : true
const moderation = moderateProfile(convo.primaryMember, moderationOpts)
const name =
convo.kind === 'group'
? convo.details.name
: createSanitizedDisplayName(
convo.primaryMember,
true,
moderation.ui('displayName'),
moderateProfile(convo.primaryMember, moderationOpts).ui(
'displayName',
),
)
const handleOnPress = useCallback(() => {
+8 -1
View File
@@ -15,6 +15,7 @@ import {
Unlock_Stroke2_Corner2_Rounded as UnlockIcon,
} from '#/components/icons/Lock'
import {PencilLine_Stroke2_Corner0_Rounded as PencilIcon} from '#/components/icons/Pencil'
import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times'
export type SystemMessageInfo = {
message: MessageDescriptor
@@ -68,7 +69,13 @@ export function getSystemMessageInfo(
} else if (ChatBskyConvoDefs.isSystemMessageDataUnlockConvo(data)) {
return {Icon: UnlockIcon, message: msg`Chat unlocked`}
} else if (ChatBskyConvoDefs.isSystemMessageDataLockConvoPermanently(data)) {
return {Icon: LockIcon, message: msg`Chat locked permanently`}
const name = getReferredDisplayName(data.lockedBy, relatedProfiles)
return {
Icon: XIcon,
message: name
? msg`${name} ended the group chat`
: msg`This group chat was ended`,
}
} else if (ChatBskyConvoDefs.isSystemMessageDataEditGroup(data)) {
return {
Icon: PencilIcon,
+1 -6
View File
@@ -69,7 +69,7 @@ export type ConvoWithDetails = {view: ChatBskyConvoDefs.ConvoView} & (
| {
kind: 'group'
details: $Typed<ChatBskyConvoDefs.GroupConvo>
primaryMember: GroupConvoMember // the owner
primaryMember?: GroupConvoMember // the owner - may have left, thus optional
members: Array<GroupConvoMember>
}
| {
@@ -117,11 +117,6 @@ export function parseConvoView(
}
}
if (!owner) {
logger.warn('No owner found in group convo')
return null
}
return {
view: convoView,
kind: 'group',