From 32b28d666229ac24cf7b1ac328d1566fb089e1a1 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 3 Feb 2025 14:37:24 -0800 Subject: Fix convo header loading state (#7603) * get initial convo state from cache * undo useConvoQuery changes * fix shadowing situation with new hook --- src/state/queries/messages/conversation.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/state/queries/messages/conversation.ts') diff --git a/src/state/queries/messages/conversation.ts b/src/state/queries/messages/conversation.ts index 9edde4aaf..260524524 100644 --- a/src/state/queries/messages/conversation.ts +++ b/src/state/queries/messages/conversation.ts @@ -1,5 +1,10 @@ import {ChatBskyConvoDefs} from '@atproto/api' -import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' +import { + QueryClient, + useMutation, + useQuery, + useQueryClient, +} from '@tanstack/react-query' import {STALE} from '#/state/queries' import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' @@ -20,7 +25,7 @@ export function useConvoQuery(convo: ChatBskyConvoDefs.ConvoView) { return useQuery({ queryKey: RQKEY(convo.id), queryFn: async () => { - const {data} = await agent.api.chat.bsky.convo.getConvo( + const {data} = await agent.chat.bsky.convo.getConvo( {convoId: convo.id}, {headers: DM_SERVICE_HEADERS}, ) @@ -31,6 +36,13 @@ export function useConvoQuery(convo: ChatBskyConvoDefs.ConvoView) { }) } +export function precacheConvoQuery( + queryClient: QueryClient, + convo: ChatBskyConvoDefs.ConvoView, +) { + queryClient.setQueryData(RQKEY(convo.id), convo) +} + export function useMarkAsReadMutation() { const optimisticUpdate = useOnMarkAsRead() const queryClient = useQueryClient() -- cgit 1.4.1