Add ability to edit group clip clop name (#10275)

This commit is contained in:
DS Boyce
2026-04-17 11:44:34 -07:00
committed by GitHub
parent 591504307d
commit adca192f3a
4 changed files with 160 additions and 13 deletions
+24 -4
View File
@@ -116,6 +116,7 @@ export class Convo {
this.isGroup = this.isGroup.bind(this)
this.getGroupInfo = this.getGroupInfo.bind(this)
this.getPrimaryMember = this.getPrimaryMember.bind(this)
this.updateGroupName = this.updateGroupName.bind(this)
}
private commit() {
@@ -655,7 +656,7 @@ export class Convo {
const nextCursor = this.oldestRev // for TS
const response = await networkRetry(2, () => {
return this.agent.api.chat.bsky.convo.getMessages(
return this.agent.chat.bsky.convo.getMessages(
{
cursor: nextCursor,
convoId: this.convoId,
@@ -889,6 +890,25 @@ export class Convo {
this.commit()
}
updateGroupName(name: string) {
if (
this.convo &&
bsky.dangerousIsType<ChatBskyConvoDefs.GroupConvo>(
this.convo.kind,
ChatBskyConvoDefs.isGroupConvo,
)
) {
this.convo = {
...this.convo,
kind: {
...this.convo.kind,
name,
},
}
}
this.commit()
}
async processPendingMessages() {
logger.debug(
`processing messages (${this.pendingMessages.size} remaining)`,
@@ -1388,14 +1408,14 @@ export class Convo {
getPrimaryMember(): ChatBskyActorDefs.ProfileViewBasic | undefined {
if (this.isGroup()) {
return this.recipients?.find(r => {
return this.convo?.members.find(m => {
if (
bsky.dangerousIsType<ChatBskyActorDefs.GroupConvoMember>(
r.kind,
m.kind,
ChatBskyActorDefs.isGroupConvoMember,
)
) {
return r.kind.role === 'owner'
return m.kind.role === 'owner'
} else {
throw new Error(
'Expected a GroupConvoMember, got an unknown kind of member',
+10 -1
View File
@@ -6,7 +6,7 @@ import {
useState,
useSyncExternalStore,
} from 'react'
import {type ChatBskyConvoDefs} from '@atproto/api'
import {ChatBskyConvoDefs} from '@atproto/api'
import {useFocusEffect} from '@react-navigation/native'
import {useQueryClient} from '@tanstack/react-query'
@@ -130,6 +130,15 @@ export function ConvoProvider({
if (data && convo.convo && data.muted !== convo.convo.muted) {
convo.updateMuted(data.muted)
}
if (
data &&
convo.convo &&
ChatBskyConvoDefs.isGroupConvo(data.kind) &&
ChatBskyConvoDefs.isGroupConvo(convo.convo.kind) &&
data.kind.name !== convo.convo.kind.name
) {
convo.updateGroupName(data.kind.name)
}
}
})
}, [convo, convoId, queryClient])