mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-04 03:25:30 +08:00
### What problem does this PR solve? Feat: Users can chat directly without first creating a conversation. #11768 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
25 lines
753 B
TypeScript
25 lines
753 B
TypeScript
import { useCallback, useState } from 'react';
|
|
import { useChatUrlParams } from './use-chat-url';
|
|
|
|
export function useHandleClickConversationCard() {
|
|
const [controller, setController] = useState(new AbortController());
|
|
const { setConversationBoth } = useChatUrlParams();
|
|
|
|
const stopOutputMessage = useCallback(() => {
|
|
setController((pre) => {
|
|
pre.abort();
|
|
return new AbortController();
|
|
});
|
|
}, []);
|
|
|
|
const handleConversationCardClick = useCallback(
|
|
(conversationId: string, isNew: boolean) => {
|
|
setConversationBoth(conversationId, isNew ? 'true' : '');
|
|
stopOutputMessage();
|
|
},
|
|
[setConversationBoth, stopOutputMessage],
|
|
);
|
|
|
|
return { controller, handleConversationCardClick, stopOutputMessage };
|
|
}
|