mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 16:46:38 +01:00
18 lines
564 B
TypeScript
18 lines
564 B
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { invoke } from '@tauri-apps/api';
|
|
import { responsesQueryKey } from './useResponses';
|
|
|
|
export function useSendRequest(id: string | null) {
|
|
const queryClient = useQueryClient();
|
|
return useMutation<void, string>({
|
|
mutationFn: async () => {
|
|
if (id === null) return;
|
|
await invoke('send_request', { requestId: id });
|
|
},
|
|
onSuccess: async () => {
|
|
if (id === null) return;
|
|
await queryClient.invalidateQueries(responsesQueryKey(id));
|
|
},
|
|
}).mutate;
|
|
}
|