mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-07 11:05:05 +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)
This commit is contained in:
@ -5,11 +5,15 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { useRemoveConversation } from '@/hooks/use-chat-request';
|
||||
import {
|
||||
useGetChatSearchParams,
|
||||
useRemoveConversation,
|
||||
} from '@/hooks/use-chat-request';
|
||||
import { IConversation } from '@/interfaces/database/chat';
|
||||
import { Trash2 } from 'lucide-react';
|
||||
import { MouseEventHandler, PropsWithChildren, useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useChatUrlParams } from '../hooks/use-chat-url';
|
||||
|
||||
export function ConversationDropdown({
|
||||
children,
|
||||
@ -20,22 +24,27 @@ export function ConversationDropdown({
|
||||
removeTemporaryConversation?: (conversationId: string) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { setConversationBoth } = useChatUrlParams();
|
||||
const { removeConversation } = useRemoveConversation();
|
||||
const { isNew } = useGetChatSearchParams();
|
||||
|
||||
const handleDelete: MouseEventHandler<HTMLDivElement> = useCallback(() => {
|
||||
if (conversation.is_new && removeTemporaryConversation) {
|
||||
removeTemporaryConversation(conversation.id);
|
||||
removeConversation([]);
|
||||
} else {
|
||||
removeConversation([conversation.id]);
|
||||
}
|
||||
}, [
|
||||
conversation.id,
|
||||
conversation.is_new,
|
||||
removeConversation,
|
||||
removeTemporaryConversation,
|
||||
]);
|
||||
const handleDelete: MouseEventHandler<HTMLDivElement> =
|
||||
useCallback(async () => {
|
||||
if (isNew === 'true' && removeTemporaryConversation) {
|
||||
removeTemporaryConversation(conversation.id);
|
||||
} else {
|
||||
const code = await removeConversation([conversation.id]);
|
||||
if (code === 0) {
|
||||
setConversationBoth('', '');
|
||||
}
|
||||
}
|
||||
}, [
|
||||
conversation.id,
|
||||
isNew,
|
||||
removeConversation,
|
||||
removeTemporaryConversation,
|
||||
setConversationBoth,
|
||||
]);
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
|
||||
Reference in New Issue
Block a user