From d87de856be410f0447e61196c1c5b49a1efea5c1 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 3 Dec 2024 10:14:36 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20WhatsApp=E6=B6=88=E6=81=AF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=8E=A5=E6=94=B6=E7=9A=84=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit todo: 引用消息时账户处理 --- src/channel/bubbleMsgUtils.js | 23 ++++++++++++++++--- .../Online/Components/BubbleIM.jsx | 11 ++------- .../Online/Components/EmailFetch.jsx | 8 +++---- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/channel/bubbleMsgUtils.js b/src/channel/bubbleMsgUtils.js index a4ad17d..244fa27 100644 --- a/src/channel/bubbleMsgUtils.js +++ b/src/channel/bubbleMsgUtils.js @@ -651,7 +651,8 @@ export const parseRenderMessageItem = (msg) => { customer_name: msg?.customerProfile?.name || '', whatsapp_name: msg?.customerProfile?.name || '', whatsapp_phone_number: isEmpty(msg?.customerProfile) ? msg.to : msg.from, - whatsapp_msg_type: (msg.msg_source || 'WABA') === 'WABA' ? msg.type : '', // 1.0接口没有msg_source + // whatsapp_msg_type: msg.msg_source==='WABA' ? msg.type : '', + // whatsapp_msg_type: (msg.msg_source || 'WABA') === 'WABA' ? msg.type : '', // 1.0接口没有msg_source statusCN: msgStatusRenderMappedCN[msg?.status || 'failed'], statusTitle: msgStatusRenderMappedCN[msg?.status || 'failed'], replyButton: ['text', 'document', 'image', 'email'].includes(msg.type) && (msg?.status || '') !== 'failed', @@ -671,7 +672,15 @@ export const parseRenderMessageItem = (msg) => { }, origin: msg.context, }), - msg_source: msg.msg_source, + msg_source: msg?.msg_source || msg.type, + ...((msg.msg_source || 'WABA') === 'WABA' ? { + whatsapp_msg_type: msg.type, + waba: msg.msg_direction === 'outbound' ? msg.from : msg.to, + wabaName: WABAccountsMapped[msg.msg_direction === 'outbound' ? msg.from : msg.to]?.verifiedName, + } : { + waba: '', + wabaName: '', + }), }; }; /** @@ -753,7 +762,15 @@ export const parseRenderMessageList = (messages) => { }), // conversationid: conversationid, // title: msg.customerProfile.name, - whatsapp_msg_type: (msg.msg_source || 'WABA') === 'WABA' ? msgContent.type : '', // 1.0接口没有msg_source + // whatsapp_msg_type: (msg.msg_source || 'WABA') === 'WABA' ? msgContent.type : '', // 1.0接口没有msg_source + ...((msg.msg_source || 'WABA') === 'WABA' ? { + whatsapp_msg_type: msgContent.type, + waba: msg.msg_direction === 'outbound' ? msgContent.from : msgContent.to, + wabaName: WABAccountsMapped[msg.msg_direction === 'outbound' ? msgContent.from : msgContent.to]?.verifiedName, + } : { + waba: '', + wabaName: '', + }), } }); }; diff --git a/src/views/Conversations/Online/Components/BubbleIM.jsx b/src/views/Conversations/Online/Components/BubbleIM.jsx index 5b9492c..cfabcfa 100644 --- a/src/views/Conversations/Online/Components/BubbleIM.jsx +++ b/src/views/Conversations/Online/Components/BubbleIM.jsx @@ -7,7 +7,6 @@ import useConversationStore from '@/stores/ConversationStore'; import { useShallow } from 'zustand/react/shallow'; import { WABIcon } from '@/components/Icons'; import ChannelLogo from './ChannelLogo'; -import { WABAccountsMapped } from '@/channel/bubbleMsgUtils'; const BubbleIM = ({ handlePreview, handleContactClick, setNewChatModalVisible, setNewChatFormValues, scrollToMessage, focusMsg, ...message }) => { const { message: appMessage } = App.useApp(); @@ -44,7 +43,6 @@ const BubbleIM = ({ handlePreview, handleContactClick, setNewChatModalVisible, s return prev; }, []); - const receivedMsgFooter = message.sender === 'me' ? '' : WABAccountsMapped[message.msgOrigin.to]?.verifiedName; return ( {headerObj ? ( @@ -77,12 +75,6 @@ const BubbleIM = ({ handlePreview, handleContactClick, setNewChatModalVisible, s } })} {footerObj ?
{footerObj.text}
: null} - {receivedMsgFooter ? ( -
- - {receivedMsgFooter} -
- ) : null} {buttonsArr && buttonsArr.length > 0 ? (
{buttonsArr.map((btn, index) => @@ -122,10 +114,11 @@ const BubbleIM = ({ handlePreview, handleContactClick, setNewChatModalVisible, s // styles: { backgroundColor: '#ccd4ae' }, notchStyle: { fill: '#ccd4ae' }, // todo: channel[WhatsApp] color '#d9fdd3' replyButton: ['text', 'document', 'image'].includes(message.whatsapp_msg_type) && message.status !== 'failed' ? true : false, - title: <> {WABAccountsMapped[message.from]?.verifiedName}, + title: <> {message.wabaName}, } : { // title: <>  {message.title}, + dateString: `${message.wabaName} - ${message.dateString}`, })} className={[ 'whitespace-pre-wrap', diff --git a/src/views/Conversations/Online/Components/EmailFetch.jsx b/src/views/Conversations/Online/Components/EmailFetch.jsx index 66faefa..1412316 100644 --- a/src/views/Conversations/Online/Components/EmailFetch.jsx +++ b/src/views/Conversations/Online/Components/EmailFetch.jsx @@ -21,16 +21,16 @@ const EmailFetch = ({ ...props }) => { key: globalNotify[0].id, message: globalNotify[0].title, description: globalNotify[0].content, - duration: 3, + duration: 0, placement: 'top', type: globalNotify[0].type, onClick: () => { clearGlobalNotify() }, }) - setTimeout(() => { - clearGlobalNotify() - }, 3030) + // setTimeout(() => { + // clearGlobalNotify() + // }, 3030) return () => {} }, [globalNotify])