diff options
author | Eric Bailey <git@esb.lol> | 2024-04-25 16:29:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 22:29:05 +0100 |
commit | 45d354cd0c76563de6d3d1146bebb750e0f6d4a0 (patch) | |
tree | 0939d1d6d91a4f812b1abeb005c6347b39692086 /src/state/queries/handle.ts | |
parent | d8c8e1e854654dbcf9585d0b3bd8c87d77df2e0f (diff) | |
download | voidsky-45d354cd0c76563de6d3d1146bebb750e0f6d4a0.tar.zst |
[Session] Add `useAgent` hook and replace (#3706)
* Hook it up * Memoize getAgent method * Use one shared reference --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/state/queries/handle.ts')
-rw-r--r-- | src/state/queries/handle.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/state/queries/handle.ts b/src/state/queries/handle.ts index ddeb35ce7..1ab275fcf 100644 --- a/src/state/queries/handle.ts +++ b/src/state/queries/handle.ts @@ -2,7 +2,7 @@ import React from 'react' import {useMutation, useQueryClient} from '@tanstack/react-query' import {STALE} from '#/state/queries' -import {getAgent} from '#/state/session' +import {useAgent} from '#/state/session' const handleQueryKeyRoot = 'handle' const fetchHandleQueryKey = (handleOrDid: string) => [ @@ -14,6 +14,7 @@ const fetchDidQueryKey = (handleOrDid: string) => [didQueryKeyRoot, handleOrDid] export function useFetchHandle() { const queryClient = useQueryClient() + const {getAgent} = useAgent() return React.useCallback( async (handleOrDid: string) => { @@ -27,12 +28,13 @@ export function useFetchHandle() { } return handleOrDid }, - [queryClient], + [queryClient, getAgent], ) } export function useUpdateHandleMutation() { const queryClient = useQueryClient() + const {getAgent} = useAgent() return useMutation({ mutationFn: async ({handle}: {handle: string}) => { @@ -48,6 +50,7 @@ export function useUpdateHandleMutation() { export function useFetchDid() { const queryClient = useQueryClient() + const {getAgent} = useAgent() return React.useCallback( async (handleOrDid: string) => { @@ -64,6 +67,6 @@ export function useFetchDid() { }, }) }, - [queryClient], + [queryClient, getAgent], ) } |