Add list of mutual chats to block dialog (#10727)

Co-authored-by: Eric Bailey <git@esb.lol>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
DS Boyce
2026-06-09 12:18:58 -07:00
committed by GitHub
parent 189dad8cb7
commit c27f50e038
7 changed files with 512 additions and 141 deletions
@@ -0,0 +1,39 @@
import {useInfiniteQuery} from '@tanstack/react-query'
import {DM_SERVICE_HEADERS} from '#/lib/constants'
import {createQueryKey} from '#/state/queries/util'
import {useAgent} from '#/state/session'
const listMutualGroupsQueryKeyRoot = 'list-mutual-groups'
export const createListMutualGroupsQueryKey = (args: {subject: string}) =>
createQueryKey(listMutualGroupsQueryKeyRoot, args)
export function useListMutualGroupsQuery({
subject,
enabled,
limit = 20,
}: {
subject: string | undefined
enabled?: boolean
limit?: number
}) {
const agent = useAgent()
const isEnabled = enabled !== false && !!subject
return useInfiniteQuery({
gcTime: 0,
staleTime: 0,
enabled: isEnabled,
queryKey: createListMutualGroupsQueryKey({subject: subject ?? ''}),
queryFn: async ({pageParam}) => {
const {data} = await agent.chat.bsky.group.listMutualGroups(
{subject: subject!, cursor: pageParam, limit},
{headers: DM_SERVICE_HEADERS},
)
return data
},
initialPageParam: undefined as string | undefined,
getNextPageParam: page => page.cursor,
})
}