30 lines
797 B
TypeScript
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,
|
|
})
|
|
}
|