about summary refs log tree commit diff
path: root/src/state/queries/like.ts
blob: 94857eb91f725daa4620faef2a56d32b81935007 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)
    },
  })
}