about summary refs log tree commit diff
path: root/src/state/queries/like.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-11-16 18:26:22 -0800
committerGitHub <noreply@github.com>2023-11-16 18:26:22 -0800
commit357c752a213dbcf77e5333fa180cfef20a33842d (patch)
treee955e57cc1252b5fe759cde29185d62bb71bc339 /src/state/queries/like.ts
parent3043b324681f1702ca53831701fb5cecd14c0efb (diff)
downloadvoidsky-357c752a213dbcf77e5333fa180cfef20a33842d.tar.zst
Move the current agent to a global and reset RQ queries on agent change (#1946)
Diffstat (limited to 'src/state/queries/like.ts')
-rw-r--r--src/state/queries/like.ts10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/state/queries/like.ts b/src/state/queries/like.ts
index 187d8fb82..94857eb91 100644
--- a/src/state/queries/like.ts
+++ b/src/state/queries/like.ts
@@ -1,24 +1,20 @@
 import {useMutation} from '@tanstack/react-query'
 
-import {useSession} from '#/state/session'
+import {getAgent} from '#/state/session'
 
 export function useLikeMutation() {
-  const {agent} = useSession()
-
   return useMutation({
     mutationFn: async ({uri, cid}: {uri: string; cid: string}) => {
-      const res = await agent.like(uri, cid)
+      const res = await getAgent().like(uri, cid)
       return {uri: res.uri}
     },
   })
 }
 
 export function useUnlikeMutation() {
-  const {agent} = useSession()
-
   return useMutation({
     mutationFn: async ({uri}: {uri: string}) => {
-      await agent.deleteLike(uri)
+      await getAgent().deleteLike(uri)
     },
   })
 }