Files
bsky-social-app/src/state/queries/post-interaction-settings.ts
T
2026-08-13 12:26:23 -07:00

30 lines
797 B
TypeScript

import {setPostInteractionSettings} from '@bsky/sdk'
import {useMutation, useQueryClient} from '@tanstack/react-query'
import {preferencesQueryKey} from '#/state/queries/preferences'
import {usePdsClient} from '#/state/session'
import {type app} from '#/lexicons'
export function usePostInteractionSettingsMutation({
onError,
onSettled,
}: {
onError?: (error: Error) => void
onSettled?: () => void
} = {}) {
const qc = useQueryClient()
const client = usePdsClient()
return useMutation({
async mutationFn(props: app.bsky.actor.defs.PostInteractionSettingsPref) {
await client.call(setPostInteractionSettings, props)
},
async onSuccess() {
await qc.invalidateQueries({
queryKey: preferencesQueryKey,
})
},
onError,
onSettled,
})
}