mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: Delete the file from the upload control of the message input box #1880 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
101 lines
2.9 KiB
TypeScript
101 lines
2.9 KiB
TypeScript
import MessageItem from '@/components/message-item';
|
|
import DocumentPreviewer from '@/components/pdf-previewer';
|
|
import { MessageType } from '@/constants/chat';
|
|
import { Drawer, Flex, Spin } from 'antd';
|
|
import {
|
|
useClickDrawer,
|
|
useFetchConversationOnMount,
|
|
useGetFileIcon,
|
|
useGetSendButtonDisabled,
|
|
useSelectConversationLoading,
|
|
useSendButtonDisabled,
|
|
useSendMessage,
|
|
} from '../hooks';
|
|
import { buildMessageItemReference } from '../utils';
|
|
|
|
import MessageInput from '@/components/message-input';
|
|
import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
|
|
import styles from './index.less';
|
|
|
|
const ChatContainer = () => {
|
|
const {
|
|
ref,
|
|
currentConversation: conversation,
|
|
addNewestConversation,
|
|
removeLatestMessage,
|
|
addNewestAnswer,
|
|
} = useFetchConversationOnMount();
|
|
const {
|
|
handleInputChange,
|
|
handlePressEnter,
|
|
value,
|
|
loading: sendLoading,
|
|
} = useSendMessage(
|
|
conversation,
|
|
addNewestConversation,
|
|
removeLatestMessage,
|
|
addNewestAnswer,
|
|
);
|
|
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
|
useClickDrawer();
|
|
const disabled = useGetSendButtonDisabled();
|
|
const sendDisabled = useSendButtonDisabled(value);
|
|
useGetFileIcon();
|
|
const loading = useSelectConversationLoading();
|
|
const { data: userInfo } = useFetchUserInfo();
|
|
|
|
return (
|
|
<>
|
|
<Flex flex={1} className={styles.chatContainer} vertical>
|
|
<Flex flex={1} vertical className={styles.messageContainer}>
|
|
<div>
|
|
<Spin spinning={loading}>
|
|
{conversation?.message?.map((message, i) => {
|
|
return (
|
|
<MessageItem
|
|
loading={
|
|
message.role === MessageType.Assistant &&
|
|
sendLoading &&
|
|
conversation?.message.length - 1 === i
|
|
}
|
|
key={message.id}
|
|
item={message}
|
|
nickname={userInfo.nickname}
|
|
avatar={userInfo.avatar}
|
|
reference={buildMessageItemReference(conversation, message)}
|
|
clickDocumentButton={clickDocumentButton}
|
|
></MessageItem>
|
|
);
|
|
})}
|
|
</Spin>
|
|
</div>
|
|
<div ref={ref} />
|
|
</Flex>
|
|
<MessageInput
|
|
disabled={disabled}
|
|
sendDisabled={sendDisabled}
|
|
sendLoading={sendLoading}
|
|
value={value}
|
|
onInputChange={handleInputChange}
|
|
onPressEnter={handlePressEnter}
|
|
conversationId={conversation.id}
|
|
></MessageInput>
|
|
</Flex>
|
|
<Drawer
|
|
title="Document Previewer"
|
|
onClose={hideModal}
|
|
open={visible}
|
|
width={'50vw'}
|
|
>
|
|
<DocumentPreviewer
|
|
documentId={documentId}
|
|
chunk={selectedChunk}
|
|
visible={visible}
|
|
></DocumentPreviewer>
|
|
</Drawer>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default ChatContainer;
|