From 9bda8945da4b4439c0b9b7737464e2f062914ed7 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 27 Nov 2024 17:02:31 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=96=B0=E5=BB=BA=E4=BC=9A=E8=AF=9D:?= =?UTF-8?q?=20=E5=8A=A0=E5=88=B0=E5=88=97=E8=A1=A8=E9=A1=B6=E9=83=A8,=20?= =?UTF-8?q?=E7=BD=AE=E9=A1=B6=E7=9A=84=E4=B8=8B=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useConversation.js | 26 +++++++++++-------- .../Conversations/Online/MessagesHeader.jsx | 7 +++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/hooks/useConversation.js b/src/hooks/useConversation.js index faca9cb..b9e6a6b 100644 --- a/src/hooks/useConversation.js +++ b/src/hooks/useConversation.js @@ -79,12 +79,13 @@ export function useConversationNewItem() { } const createdNew = await postNewOrEditConversationItem({ ...newChat, opisn: opisn || userId, conversationid }); // addToConversationList([{...createdNew, sn: createdNew.conversationid}]); - const _list = await fetchConversationsList({ opisn }); - addToConversationList(_list); - if (!body.conversationid) { - const newChat = _list.find((item) => item.sn === createdNew.conversationid) - if (isEmpty(newChat)) { - setCurrentConversation({ + // const _list = await fetchConversationsList({ opisn }); + // addToConversationList(_list, 'top'); + if (isEmpty(body.conversationid)) { + // const newChat = _list.find((item) => item.sn === createdNew.conversationid) + const newChat = createdNew; + if (!isEmpty(newChat)) { + const buildChatItem = { ...CHAT_ITEM_RECORD, ...createdNew, sn: createdNew.conversationid, @@ -96,13 +97,16 @@ export function useConversationNewItem() { conversation_memo: createdNew.remark, lasttime: createdNew.session_creatime, show_default: createdNew.remark || createdNew.guest_name || createdNew.guest_phone || createdNew.guest_email || createdNew.whatsapp_phone_number || '', - }) + } + + setCurrentConversation(buildChatItem); + addToConversationList([buildChatItem], 'top'); return ; } - setCurrentConversation({ - ...newChat, - show_default: newChat.conversation_memo || newChat.whatsapp_name || newChat?.channels?.whatsapp_phone_number || newChat?.channels?.phone_number || newChat?.channels?.email || '', - }) + // setCurrentConversation({ + // ...newChat, + // show_default: newChat.conversation_memo || newChat.whatsapp_name || newChat?.channels?.whatsapp_phone_number || newChat?.channels?.phone_number || newChat?.channels?.email || '', + // }) return ; } }; diff --git a/src/views/Conversations/Online/MessagesHeader.jsx b/src/views/Conversations/Online/MessagesHeader.jsx index b405072..3597e69 100644 --- a/src/views/Conversations/Online/MessagesHeader.jsx +++ b/src/views/Conversations/Online/MessagesHeader.jsx @@ -38,9 +38,12 @@ const MessagesHeader = () => { {(currentConversation.coli_sn || currentConversation.sn) ? ( <> - {currentConversation.customer_name} + {currentConversation.show_default} {currentConversation.sn ? ( - {currentConversation.show_default} + <> + {currentConversation?.channels?.whatsapp_phone_number} + {currentConversation?.channels?.email} + ) : ( 没有WhatsApp号码