Refactor useConvoQuery
This commit is contained in:
@@ -74,7 +74,10 @@ let ConvoMenu = ({
|
|||||||
}, [modui])
|
}, [modui])
|
||||||
const isBlocking = !!userBlock || !!listBlocks.length
|
const isBlocking = !!userBlock || !!listBlocks.length
|
||||||
|
|
||||||
const {data: convo} = useConvoQuery(initialConvo)
|
const {data: convo} = useConvoQuery(
|
||||||
|
{convoId: initialConvo.id},
|
||||||
|
{initialData: initialConvo},
|
||||||
|
)
|
||||||
|
|
||||||
const onNavigateToProfile = useCallback(() => {
|
const onNavigateToProfile = useCallback(() => {
|
||||||
navigation.navigate('Profile', {name: profile.did})
|
navigation.navigate('Profile', {name: profile.did})
|
||||||
|
|||||||
@@ -9,19 +9,22 @@ import {RQKEY as LIST_CONVOS_KEY} from './list-converations'
|
|||||||
const RQKEY_ROOT = 'convo'
|
const RQKEY_ROOT = 'convo'
|
||||||
export const RQKEY = (convoId: string) => [RQKEY_ROOT, convoId]
|
export const RQKEY = (convoId: string) => [RQKEY_ROOT, convoId]
|
||||||
|
|
||||||
export function useConvoQuery(convo: ChatBskyConvoDefs.ConvoView) {
|
export function useConvoQuery(
|
||||||
|
{convoId}: {convoId: string},
|
||||||
|
options?: {initialData: ChatBskyConvoDefs.ConvoView},
|
||||||
|
) {
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: RQKEY(convo.id),
|
queryKey: RQKEY(convoId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {data} = await getAgent().api.chat.bsky.convo.getConvo(
|
const {data} = await getAgent().api.chat.bsky.convo.getConvo(
|
||||||
{convoId: convo.id},
|
{convoId: convoId},
|
||||||
{headers: DM_SERVICE_HEADERS},
|
{headers: DM_SERVICE_HEADERS},
|
||||||
)
|
)
|
||||||
return data.convo
|
return data.convo
|
||||||
},
|
},
|
||||||
initialData: convo,
|
initialData: options?.initialData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user