forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {type AppBskyActorDefs} from '@atproto/api'
2import {useMutation, useQueryClient} from '@tanstack/react-query'
3
4import {preferencesQueryKey} from '#/state/queries/preferences'
5import {useAgent} from '#/state/session'
6import {pdsAgent} from '../session/agent'
7
8export function usePostInteractionSettingsMutation({
9 onError,
10 onSettled,
11}: {
12 onError?: (error: Error) => void
13 onSettled?: () => void
14} = {}) {
15 const qc = useQueryClient()
16 const agent = useAgent()
17 return useMutation({
18 async mutationFn(props: AppBskyActorDefs.PostInteractionSettingsPref) {
19 await pdsAgent(agent).setPostInteractionSettings(props)
20 },
21 async onSuccess() {
22 await qc.invalidateQueries({
23 queryKey: preferencesQueryKey,
24 })
25 },
26 onError,
27 onSettled,
28 })
29}