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:
@@ -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,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user