mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Displays the loading status of the data flow log #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
22 lines
515 B
TypeScript
22 lines
515 B
TypeScript
import { useCancelDataflow } from '@/hooks/use-agent-request';
|
|
import { useCallback } from 'react';
|
|
|
|
export function useCancelCurrentDataflow({
|
|
messageId,
|
|
stopFetchTrace,
|
|
}: {
|
|
messageId: string;
|
|
stopFetchTrace(): void;
|
|
}) {
|
|
const { cancelDataflow } = useCancelDataflow();
|
|
|
|
const handleCancel = useCallback(async () => {
|
|
const code = await cancelDataflow(messageId);
|
|
if (code === 0) {
|
|
stopFetchTrace();
|
|
}
|
|
}, [cancelDataflow, messageId, stopFetchTrace]);
|
|
|
|
return { handleCancel };
|
|
}
|