diff options
author | Eric Bailey <git@esb.lol> | 2024-05-14 09:22:09 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 09:22:09 -0500 |
commit | 9173be686c1df9adc6cbb9cc2175f8909a868c35 (patch) | |
tree | 25ea67a686969a086249769a1a3a445cd819a9ff /src/state/queries/messages/conversation.ts | |
parent | 107760d551dee695f76409337048cd8c7917b784 (diff) | |
download | voidsky-9173be686c1df9adc6cbb9cc2175f8909a868c35.tar.zst |
[🐴] Swap in new package, update usages (#3992)
* Swap in new package, update usages * Remove uneccessary patch * Override type in safe place
Diffstat (limited to 'src/state/queries/messages/conversation.ts')
-rw-r--r-- | src/state/queries/messages/conversation.ts | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/state/queries/messages/conversation.ts b/src/state/queries/messages/conversation.ts index e420ba736..bd5b746f1 100644 --- a/src/state/queries/messages/conversation.ts +++ b/src/state/queries/messages/conversation.ts @@ -1,26 +1,23 @@ -import {BskyAgent} from '@atproto-labs/api' -import {ConvoView} from '@atproto-labs/api/dist/client/types/chat/bsky/convo/defs' +import {ChatBskyConvoDefs} from '@atproto/api' import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' +import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' import {useOnMarkAsRead} from '#/state/queries/messages/list-converations' -import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' +import {useAgent} from '#/state/session' import {RQKEY as LIST_CONVOS_KEY} from './list-converations' -import {useHeaders} from './temp-headers' const RQKEY_ROOT = 'convo' export const RQKEY = (convoId: string) => [RQKEY_ROOT, convoId] -export function useConvoQuery(convo: ConvoView) { - const headers = useHeaders() - const {serviceUrl} = useDmServiceUrlStorage() +export function useConvoQuery(convo: ChatBskyConvoDefs.ConvoView) { + const {getAgent} = useAgent() return useQuery({ queryKey: RQKEY(convo.id), queryFn: async () => { - const agent = new BskyAgent({service: serviceUrl}) - const {data} = await agent.api.chat.bsky.convo.getConvo( + const {data} = await getAgent().api.chat.bsky.convo.getConvo( {convoId: convo.id}, - {headers}, + {headers: DM_SERVICE_HEADERS}, ) return data.convo }, @@ -29,10 +26,9 @@ export function useConvoQuery(convo: ConvoView) { } export function useMarkAsReadMutation() { - const headers = useHeaders() - const {serviceUrl} = useDmServiceUrlStorage() const optimisticUpdate = useOnMarkAsRead() const queryClient = useQueryClient() + const {getAgent} = useAgent() return useMutation({ mutationFn: async ({ @@ -44,15 +40,14 @@ export function useMarkAsReadMutation() { }) => { if (!convoId) throw new Error('No convoId provided') - const agent = new BskyAgent({service: serviceUrl}) - await agent.api.chat.bsky.convo.updateRead( + await getAgent().api.chat.bsky.convo.updateRead( { convoId, messageId, }, { encoding: 'application/json', - headers, + headers: DM_SERVICE_HEADERS, }, ) }, |