diff options
Diffstat (limited to 'src/state/queries/messages')
-rw-r--r-- | src/state/queries/messages/actor-declaration.ts | 8 | ||||
-rw-r--r-- | src/state/queries/messages/conversation.ts | 8 | ||||
-rw-r--r-- | src/state/queries/messages/get-convo-for-members.ts | 13 | ||||
-rw-r--r-- | src/state/queries/messages/leave-conversation.ts | 4 | ||||
-rw-r--r-- | src/state/queries/messages/list-converations.tsx | 4 | ||||
-rw-r--r-- | src/state/queries/messages/mute-conversation.ts | 4 |
6 files changed, 18 insertions, 23 deletions
diff --git a/src/state/queries/messages/actor-declaration.ts b/src/state/queries/messages/actor-declaration.ts index d6a86cf69..1105e2b3c 100644 --- a/src/state/queries/messages/actor-declaration.ts +++ b/src/state/queries/messages/actor-declaration.ts @@ -14,12 +14,12 @@ export function useUpdateActorDeclaration({ }) { const queryClient = useQueryClient() const {currentAccount} = useSession() - const {getAgent} = useAgent() + const agent = useAgent() return useMutation({ mutationFn: async (allowIncoming: 'all' | 'none' | 'following') => { if (!currentAccount) throw new Error('Not logged in') - const result = await getAgent().api.com.atproto.repo.putRecord({ + const result = await agent.api.com.atproto.repo.putRecord({ repo: currentAccount.did, collection: 'chat.bsky.actor.declaration', rkey: 'self', @@ -64,13 +64,13 @@ export function useUpdateActorDeclaration({ // for use in the settings screen for testing export function useDeleteActorDeclaration() { const {currentAccount} = useSession() - const {getAgent} = useAgent() + const agent = useAgent() return useMutation({ mutationFn: async () => { if (!currentAccount) throw new Error('Not logged in') // TODO(sam): remove validate: false once PDSes have the new lexicon - const result = await getAgent().api.com.atproto.repo.deleteRecord({ + const result = await agent.api.com.atproto.repo.deleteRecord({ repo: currentAccount.did, collection: 'chat.bsky.actor.declaration', rkey: 'self', diff --git a/src/state/queries/messages/conversation.ts b/src/state/queries/messages/conversation.ts index baf69223a..16ace3c5a 100644 --- a/src/state/queries/messages/conversation.ts +++ b/src/state/queries/messages/conversation.ts @@ -11,12 +11,12 @@ const RQKEY_ROOT = 'convo' export const RQKEY = (convoId: string) => [RQKEY_ROOT, convoId] export function useConvoQuery(convo: ChatBskyConvoDefs.ConvoView) { - const {getAgent} = useAgent() + const agent = useAgent() return useQuery({ queryKey: RQKEY(convo.id), queryFn: async () => { - const {data} = await getAgent().api.chat.bsky.convo.getConvo( + const {data} = await agent.api.chat.bsky.convo.getConvo( {convoId: convo.id}, {headers: DM_SERVICE_HEADERS}, ) @@ -30,7 +30,7 @@ export function useConvoQuery(convo: ChatBskyConvoDefs.ConvoView) { export function useMarkAsReadMutation() { const optimisticUpdate = useOnMarkAsRead() const queryClient = useQueryClient() - const {getAgent} = useAgent() + const agent = useAgent() return useMutation({ mutationFn: async ({ @@ -42,7 +42,7 @@ export function useMarkAsReadMutation() { }) => { if (!convoId) throw new Error('No convoId provided') - await getAgent().api.chat.bsky.convo.updateRead( + await agent.api.chat.bsky.convo.updateRead( { convoId, messageId, diff --git a/src/state/queries/messages/get-convo-for-members.ts b/src/state/queries/messages/get-convo-for-members.ts index a260d5416..7979e0665 100644 --- a/src/state/queries/messages/get-convo-for-members.ts +++ b/src/state/queries/messages/get-convo-for-members.ts @@ -18,11 +18,11 @@ export function useGetConvoForMembers({ onError?: (error: Error) => void }) { const queryClient = useQueryClient() - const {getAgent} = useAgent() + const agent = useAgent() return useMutation({ mutationFn: async (members: string[]) => { - const {data} = await getAgent().api.chat.bsky.convo.getConvoForMembers( + const {data} = await agent.api.chat.bsky.convo.getConvoForMembers( {members: members}, {headers: DM_SERVICE_HEADERS}, ) @@ -44,16 +44,13 @@ export function useGetConvoForMembers({ * Gets the conversation ID for a given DID. Returns null if it's not possible to message them. */ export function useMaybeConvoForUser(did: string) { - const {getAgent} = useAgent() + const agent = useAgent() return useQuery({ queryKey: RQKEY(did), queryFn: async () => { - const convo = await getAgent() - .api.chat.bsky.convo.getConvoForMembers( - {members: [did]}, - {headers: DM_SERVICE_HEADERS}, - ) + const convo = await agent.api.chat.bsky.convo + .getConvoForMembers({members: [did]}, {headers: DM_SERVICE_HEADERS}) .catch(() => ({success: null})) if (convo.success) { diff --git a/src/state/queries/messages/leave-conversation.ts b/src/state/queries/messages/leave-conversation.ts index 9f45de544..29c71a606 100644 --- a/src/state/queries/messages/leave-conversation.ts +++ b/src/state/queries/messages/leave-conversation.ts @@ -17,13 +17,13 @@ export function useLeaveConvo( }, ) { const queryClient = useQueryClient() - const {getAgent} = useAgent() + const agent = useAgent() return useMutation({ mutationFn: async () => { if (!convoId) throw new Error('No convoId provided') - const {data} = await getAgent().api.chat.bsky.convo.leaveConvo( + const {data} = await agent.api.chat.bsky.convo.leaveConvo( {convoId}, {headers: DM_SERVICE_HEADERS, encoding: 'application/json'}, ) diff --git a/src/state/queries/messages/list-converations.tsx b/src/state/queries/messages/list-converations.tsx index 13a4a3bf2..46892f6ae 100644 --- a/src/state/queries/messages/list-converations.tsx +++ b/src/state/queries/messages/list-converations.tsx @@ -27,12 +27,12 @@ export const RQKEY = ['convo-list'] type RQPageParam = string | undefined export function useListConvosQuery() { - const {getAgent} = useAgent() + const agent = useAgent() return useInfiniteQuery({ queryKey: RQKEY, queryFn: async ({pageParam}) => { - const {data} = await getAgent().api.chat.bsky.convo.listConvos( + const {data} = await agent.api.chat.bsky.convo.listConvos( {cursor: pageParam}, {headers: DM_SERVICE_HEADERS}, ) diff --git a/src/state/queries/messages/mute-conversation.ts b/src/state/queries/messages/mute-conversation.ts index fa760e00d..bc383fde1 100644 --- a/src/state/queries/messages/mute-conversation.ts +++ b/src/state/queries/messages/mute-conversation.ts @@ -21,13 +21,11 @@ export function useMuteConvo( }, ) { const queryClient = useQueryClient() - const {getAgent} = useAgent() + const agent = useAgent() return useMutation({ mutationFn: async ({mute}: {mute: boolean}) => { if (!convoId) throw new Error('No convoId provided') - - const agent = getAgent() if (mute) { const {data} = await agent.api.chat.bsky.convo.muteConvo( {convoId}, |