mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 21:53:36 +01:00
20 lines
715 B
TypeScript
20 lines
715 B
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { invoke } from '@tauri-apps/api';
|
|
import { trackEvent } from '../lib/analytics';
|
|
import { httpResponsesQueryKey } from './useHttpResponses';
|
|
|
|
export function useDeleteHttpResponses(requestId?: string) {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: async () => {
|
|
if (requestId === undefined) return;
|
|
await invoke('cmd_delete_all_http_responses', { requestId });
|
|
},
|
|
onSettled: () => trackEvent('HttpResponse', 'DeleteMany'),
|
|
onSuccess: async () => {
|
|
if (requestId === undefined) return;
|
|
queryClient.setQueryData(httpResponsesQueryKey({ requestId }), []);
|
|
},
|
|
});
|
|
}
|