bsky-app/src/state/queries/like.ts
dan 9bd411c151
Replace getAgent() with reading agent (#4243)
* Replace getAgent() with agent

* Replace {agent} with agent
2024-05-28 16:37:51 +01:00

22 lines
521 B
TypeScript

import {useMutation} from '@tanstack/react-query'
import {useAgent} from '#/state/session'
export function useLikeMutation() {
const agent = useAgent()
return useMutation({
mutationFn: async ({uri, cid}: {uri: string; cid: string}) => {
const res = await agent.like(uri, cid)
return {uri: res.uri}
},
})
}
export function useUnlikeMutation() {
const agent = useAgent()
return useMutation({
mutationFn: async ({uri}: {uri: string}) => {
await agent.deleteLike(uri)
},
})
}