diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-11-16 18:26:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 18:26:22 -0800 |
commit | 357c752a213dbcf77e5333fa180cfef20a33842d (patch) | |
tree | e955e57cc1252b5fe759cde29185d62bb71bc339 /src/state/queries/app-passwords.ts | |
parent | 3043b324681f1702ca53831701fb5cecd14c0efb (diff) | |
download | voidsky-357c752a213dbcf77e5333fa180cfef20a33842d.tar.zst |
Move the current agent to a global and reset RQ queries on agent change (#1946)
Diffstat (limited to 'src/state/queries/app-passwords.ts')
-rw-r--r-- | src/state/queries/app-passwords.ts | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/state/queries/app-passwords.ts b/src/state/queries/app-passwords.ts index 9aadfe2e4..6a7e43610 100644 --- a/src/state/queries/app-passwords.ts +++ b/src/state/queries/app-passwords.ts @@ -1,25 +1,23 @@ import {ComAtprotoServerCreateAppPassword} from '@atproto/api' import {useQuery, useQueryClient, useMutation} from '@tanstack/react-query' -import {useSession} from '#/state/session' import {STALE} from '#/state/queries' +import {getAgent} from '../session' export const RQKEY = () => ['app-passwords'] export function useAppPasswordsQuery() { - const {agent} = useSession() return useQuery({ staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(), queryFn: async () => { - const res = await agent.com.atproto.server.listAppPasswords({}) + const res = await getAgent().com.atproto.server.listAppPasswords({}) return res.data.passwords }, }) } export function useAppPasswordCreateMutation() { - const {agent} = useSession() const queryClient = useQueryClient() return useMutation< ComAtprotoServerCreateAppPassword.OutputSchema, @@ -28,7 +26,7 @@ export function useAppPasswordCreateMutation() { >({ mutationFn: async ({name}) => { return ( - await agent.com.atproto.server.createAppPassword({ + await getAgent().com.atproto.server.createAppPassword({ name, }) ).data @@ -42,11 +40,10 @@ export function useAppPasswordCreateMutation() { } export function useAppPasswordDeleteMutation() { - const {agent} = useSession() const queryClient = useQueryClient() return useMutation<void, Error, {name: string}>({ mutationFn: async ({name}) => { - await agent.com.atproto.server.revokeAppPassword({ + await getAgent().com.atproto.server.revokeAppPassword({ name, }) }, |