mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 16:23:25 +01:00
21 lines
775 B
TypeScript
21 lines
775 B
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { trackEvent } from '../lib/analytics';
|
|
import { invokeCmd } from '../lib/tauri';
|
|
import { httpResponsesQueryKey } from './useHttpResponses';
|
|
|
|
export function useDeleteHttpResponses(requestId?: string) {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationKey: ['delete_http_responses', requestId],
|
|
mutationFn: async () => {
|
|
if (requestId === undefined) return;
|
|
await invokeCmd('cmd_delete_all_http_responses', { requestId });
|
|
},
|
|
onSettled: () => trackEvent('http_response', 'delete_many'),
|
|
onSuccess: async () => {
|
|
if (requestId === undefined) return;
|
|
queryClient.setQueryData(httpResponsesQueryKey({ requestId }), []);
|
|
},
|
|
});
|
|
}
|