diff options
Diffstat (limited to 'src/state/queries/like.ts')
-rw-r--r-- | src/state/queries/like.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/state/queries/like.ts b/src/state/queries/like.ts new file mode 100644 index 000000000..94857eb91 --- /dev/null +++ b/src/state/queries/like.ts @@ -0,0 +1,20 @@ +import {useMutation} from '@tanstack/react-query' + +import {getAgent} from '#/state/session' + +export function useLikeMutation() { + return useMutation({ + mutationFn: async ({uri, cid}: {uri: string; cid: string}) => { + const res = await getAgent().like(uri, cid) + return {uri: res.uri} + }, + }) +} + +export function useUnlikeMutation() { + return useMutation({ + mutationFn: async ({uri}: {uri: string}) => { + await getAgent().deleteLike(uri) + }, + }) +} |