diff options
Diffstat (limited to 'src/state/queries/post-interaction-settings.ts')
-rw-r--r-- | src/state/queries/post-interaction-settings.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/state/queries/post-interaction-settings.ts b/src/state/queries/post-interaction-settings.ts new file mode 100644 index 000000000..a256f2956 --- /dev/null +++ b/src/state/queries/post-interaction-settings.ts @@ -0,0 +1,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, + }) + }, + }) +} |