diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-02-03 14:37:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-03 22:37:24 +0000 |
commit | 32b28d666229ac24cf7b1ac328d1566fb089e1a1 (patch) | |
tree | 2e721117c9a859ca1cae52e1c15642d5e6db4d5b /src/state/queries | |
parent | fa8607b861e0719d76778aa14af0745313640e33 (diff) | |
download | voidsky-32b28d666229ac24cf7b1ac328d1566fb089e1a1.tar.zst |
Fix convo header loading state (#7603)
* get initial convo state from cache * undo useConvoQuery changes * fix shadowing situation with new hook
Diffstat (limited to 'src/state/queries')
-rw-r--r-- | src/state/queries/messages/conversation.ts | 16 |
1 files changed, 14 insertions, 2 deletions
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() |