|
|
@ -1,11 +1,11 @@
|
|
|
|
import { useEffect, useState, useRef, useMemo } from 'react';
|
|
|
|
import { useEffect, useState, useRef, useMemo } from 'react';
|
|
|
|
import { Image, Alert } from 'antd';
|
|
|
|
import { Image, Spin } from 'antd';
|
|
|
|
import { MessageBox } from 'react-chat-elements';
|
|
|
|
import { MessageBox } from 'react-chat-elements';
|
|
|
|
import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
import { useShallow } from 'zustand/react/shallow';
|
|
|
|
import { useShallow } from 'zustand/react/shallow';
|
|
|
|
|
|
|
|
|
|
|
|
const Messages = () => {
|
|
|
|
const Messages = () => {
|
|
|
|
const { currentConversation, setReferenceMsg } = useConversationStore();
|
|
|
|
const { currentConversation, setReferenceMsg, msgListLoading, } = useConversationStore();
|
|
|
|
const activeMessages = useConversationStore(useShallow((state) => (currentConversation.sn ? state.activeConversations[currentConversation.sn] : [])));
|
|
|
|
const activeMessages = useConversationStore(useShallow((state) => (currentConversation.sn ? state.activeConversations[currentConversation.sn] : [])));
|
|
|
|
|
|
|
|
|
|
|
|
const messagesList = useMemo(
|
|
|
|
const messagesList = useMemo(
|
|
|
@ -50,11 +50,13 @@ const Messages = () => {
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<Spin spinning={msgListLoading} tip={'正在读取...'} wrapperClassName='pt-8 ' >
|
|
|
|
{messagesList.map((message, index) => (
|
|
|
|
{messagesList.map((message, index) => (
|
|
|
|
<MessageBox key={message.key} {...message} onReplyClick={() => setReferenceMsg(message)} onOpen={() => handlePreview(message)} />
|
|
|
|
<MessageBox key={message.key} {...message} onReplyClick={() => setReferenceMsg(message)} onOpen={() => handlePreview(message)} />
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
<Image src={previewSrc} preview={{ visible: previewVisible, src: previewSrc, onClose: onPreviewClose }} />
|
|
|
|
<Image src={previewSrc} preview={{ visible: previewVisible, src: previewSrc, onClose: onPreviewClose }} />
|
|
|
|
<div ref={messagesEndRef}></div>
|
|
|
|
<div ref={messagesEndRef}></div>
|
|
|
|
|
|
|
|
</Spin>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|