about summary refs log tree commit diff
path: root/src/state/queries/list.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-04-25 16:29:05 -0500
committerGitHub <noreply@github.com>2024-04-25 22:29:05 +0100
commit45d354cd0c76563de6d3d1146bebb750e0f6d4a0 (patch)
tree0939d1d6d91a4f812b1abeb005c6347b39692086 /src/state/queries/list.ts
parentd8c8e1e854654dbcf9585d0b3bd8c87d77df2e0f (diff)
downloadvoidsky-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/list.ts')
-rw-r--r--src/state/queries/list.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/state/queries/list.ts b/src/state/queries/list.ts
index 1edf2606c..dd2e21fb6 100644
--- a/src/state/queries/list.ts
+++ b/src/state/queries/list.ts
@@ -13,7 +13,7 @@ import chunk from 'lodash.chunk'
 import {uploadBlob} from '#/lib/api'
 import {until} from '#/lib/async/until'
 import {STALE} from '#/state/queries'
-import {getAgent, useSession} from '../session'
+import {useAgent, useSession} from '../session'
 import {invalidate as invalidateMyLists} from './my-lists'
 import {RQKEY as PROFILE_LISTS_RQKEY} from './profile-lists'
 
@@ -21,6 +21,7 @@ const RQKEY_ROOT = 'list'
 export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
 
 export function useListQuery(uri?: string) {
+  const {getAgent} = useAgent()
   return useQuery<AppBskyGraphDefs.ListView, Error>({
     staleTime: STALE.MINUTES.ONE,
     queryKey: RQKEY(uri || ''),
@@ -48,6 +49,7 @@ export interface ListCreateMutateParams {
 export function useListCreateMutation() {
   const {currentAccount} = useSession()
   const queryClient = useQueryClient()
+  const {getAgent} = useAgent()
   return useMutation<{uri: string; cid: string}, Error, ListCreateMutateParams>(
     {
       async mutationFn({
@@ -114,6 +116,7 @@ export interface ListMetadataMutateParams {
 }
 export function useListMetadataMutation() {
   const {currentAccount} = useSession()
+  const {getAgent} = useAgent()
   const queryClient = useQueryClient()
   return useMutation<
     {uri: string; cid: string},
@@ -181,6 +184,7 @@ export function useListMetadataMutation() {
 
 export function useListDeleteMutation() {
   const {currentAccount} = useSession()
+  const {getAgent} = useAgent()
   const queryClient = useQueryClient()
   return useMutation<void, Error, {uri: string}>({
     mutationFn: async ({uri}) => {
@@ -249,6 +253,7 @@ export function useListDeleteMutation() {
 
 export function useListMuteMutation() {
   const queryClient = useQueryClient()
+  const {getAgent} = useAgent()
   return useMutation<void, Error, {uri: string; mute: boolean}>({
     mutationFn: async ({uri, mute}) => {
       if (mute) {
@@ -275,6 +280,7 @@ export function useListMuteMutation() {
 
 export function useListBlockMutation() {
   const queryClient = useQueryClient()
+  const {getAgent} = useAgent()
   return useMutation<void, Error, {uri: string; block: boolean}>({
     mutationFn: async ({uri, block}) => {
       if (block) {