mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-02-22 23:57:57 +01:00
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import type {WebsocketRequest} from "@yaakapp-internal/models";
|
|
import { deleteWebsocketRequest as cmdDeleteWebsocketRequest } from '@yaakapp-internal/ws';
|
|
import { InlineCode } from '../components/core/InlineCode';
|
|
import { createFastMutation } from '../hooks/useFastMutation';
|
|
import { trackEvent } from '../lib/analytics';
|
|
import { showConfirm } from '../lib/confirm';
|
|
import { fallbackRequestName } from '../lib/fallbackRequestName';
|
|
|
|
export const deleteWebsocketRequest = createFastMutation({
|
|
mutationKey: ['delete_websocket_request'],
|
|
mutationFn: async (request: WebsocketRequest) => {
|
|
const confirmed = await showConfirm({
|
|
id: 'delete-websocket-request',
|
|
title: 'Delete WebSocket Request',
|
|
variant: 'delete',
|
|
description: (
|
|
<>
|
|
Permanently delete <InlineCode>{fallbackRequestName(request)}</InlineCode>?
|
|
</>
|
|
),
|
|
});
|
|
if (!confirmed) {
|
|
return null;
|
|
}
|
|
|
|
return cmdDeleteWebsocketRequest(request.id);
|
|
},
|
|
onSuccess: async () => {
|
|
trackEvent('websocket_request', 'delete');
|
|
},
|
|
});
|