about summary refs log tree commit diff
path: root/src/state/queries/post-interaction-settings.ts
blob: a256f29561a650f6914d9e7a5b8438d85f06a9a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import {AppBskyActorDefs} from '@atproto/api'
import {useMutation, useQueryClient} from '@tanstack/react-query'

import {preferencesQueryKey} from '#/state/queries/preferences'
import {useAgent} from '#/state/session'

export function usePostInteractionSettingsMutation() {
  const qc = useQueryClient()
  const agent = useAgent()
  return useMutation({
    async mutationFn(props: AppBskyActorDefs.PostInteractionSettingsPref) {
      await agent.setPostInteractionSettings(props)
    },
    async onSuccess() {
      await qc.invalidateQueries({
        queryKey: preferencesQueryKey,
      })
    },
  })
}