From 27832f452ba4654ee8409912b58f5c7cce1d7ec9 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 15 Mar 2024 09:23:21 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=9A=E8=AF=9D=E6=8F=90=E7=A4=BA=0B?= =?UTF-8?q?perf:=20text=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA=E5=AE=A2?= =?UTF-8?q?=E4=BA=BA=E7=9A=84=E6=98=B5=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 有会话才获取消息记录 --- src/actions/ConversationActions.js | 2 +- src/lib/msgUtils.js | 2 +- src/views/ChatHistory.jsx | 1 + .../Conversations/Components/ConversationsList.jsx | 2 +- .../Conversations/Components/MessagesHeader.jsx | 14 ++++++++++---- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/actions/ConversationActions.js b/src/actions/ConversationActions.js index b3744c3..e12a4c6 100644 --- a/src/actions/ConversationActions.js +++ b/src/actions/ConversationActions.js @@ -35,7 +35,7 @@ export const fetchOrderConversationsList = async (params) => { return list; }; -export const MESSAGE_PAGE_SIZE = 100; +export const MESSAGE_PAGE_SIZE = 50; /** * * @param {object} params { opisn, whatsappid, lasttime, pagesize } diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index cf98c69..35bcc13 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -255,7 +255,7 @@ export const whatsappMsgTypeMapped = { }, text: { type: 'text', - data: (msg) => ({ id: msg.wamid, text: autoLinkText(msg.text.body), originText: msg.text.body }), + data: (msg) => ({ id: msg.wamid, text: autoLinkText(msg.text.body), originText: msg.text.body, title: msg?.customerProfile?.name || '' }), renderForReply: (msg) => ({ id: msg.wamid, message: msg.text.body }), }, image: { diff --git a/src/views/ChatHistory.jsx b/src/views/ChatHistory.jsx index 6c48663..67f176a 100644 --- a/src/views/ChatHistory.jsx +++ b/src/views/ChatHistory.jsx @@ -248,6 +248,7 @@ function ChatHistory() { onOpen={() => handlePreview(message)} onTitleClick={() => handlePreview(message)} notch={false} + title={message.type === 'text' ? '' : message.title} text={} copiableDate={true} dateString={message.dateString || message.localDate} diff --git a/src/views/Conversations/Components/ConversationsList.jsx b/src/views/Conversations/Components/ConversationsList.jsx index 7e1af6d..675653d 100644 --- a/src/views/Conversations/Components/ConversationsList.jsx +++ b/src/views/Conversations/Components/ConversationsList.jsx @@ -82,7 +82,7 @@ const Conversations = () => { useEffect(() => { const messagesList = activeConversations[`${currentConversation.sn}`] || []; - if (messagesList.length < 20) { + if (currentConversation.sn && messagesList.length < 20) { getMessages(currentConversation); } diff --git a/src/views/Conversations/Components/MessagesHeader.jsx b/src/views/Conversations/Components/MessagesHeader.jsx index 9dbeb96..3ae041a 100644 --- a/src/views/Conversations/Components/MessagesHeader.jsx +++ b/src/views/Conversations/Components/MessagesHeader.jsx @@ -34,14 +34,20 @@ const MessagesHeader = () => { {/* {currentConversation.customer_name && } */} - {currentConversation.whatsapp_phone_number ? ( + {(currentConversation.coli_sn || currentConversation.sn) ? ( <> {currentConversation.customer_name} - {currentConversation.whatsapp_phone_number} + {currentConversation.whatsapp_phone_number ? ( + {currentConversation.whatsapp_phone_number} + ) : ( + + 没有WhatsApp号码 + + )} ) : ( - - 没有WhatsApp号码 + + 请选择会话 )}