mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 08:36:40 +01:00
22 lines
815 B
TypeScript
22 lines
815 B
TypeScript
import { useFastMutation } from './useFastMutation';
|
|
import type { HttpResponse } from '@yaakapp-internal/models';
|
|
import {useSetAtom} from "jotai";
|
|
import { trackEvent } from '../lib/analytics';
|
|
import { invokeCmd } from '../lib/tauri';
|
|
import {httpResponsesAtom} from "./useHttpResponses";
|
|
import {removeModelById} from "./useSyncModelStores";
|
|
|
|
export function useDeleteHttpResponse(id: string | null) {
|
|
const setHttpResponses = useSetAtom(httpResponsesAtom);
|
|
return useFastMutation<HttpResponse>({
|
|
mutationKey: ['delete_http_response', id],
|
|
mutationFn: async () => {
|
|
return await invokeCmd('cmd_delete_http_response', { id: id });
|
|
},
|
|
onSettled: () => trackEvent('http_response', 'delete'),
|
|
onSuccess: (response) => {
|
|
setHttpResponses(removeModelById(response));
|
|
}
|
|
});
|
|
}
|