From fa4279232ea32d42f3b3e23c2f83e11f99a8ac3a Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 14 Mar 2024 10:10:05 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=81=94=E7=B3=BB=E4=BA=BA=E6=B6=88?= =?UTF-8?q?=E6=81=AF:=20=E6=9C=89wa=5Fid=20=E6=89=8D=E8=83=BD=E5=8F=91?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/msgUtils.js | 3 ++- .../Conversations/Components/MessagesList.jsx | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index ce52875..cf98c69 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -379,7 +379,8 @@ export const whatsappMsgTypeMapped = { meetingID: msg.wamid, title: msg.contacts.length === 1 ? `联系人` : `${msg.contacts.length} 位联系人`, text: msg.contacts.map((ele) => `${(ele?.org?.company || '') +' '+ele.name.formatted_name}: ${ele.phones[0].wa_id || ele.phones[0].phone}`).join('\n'), - data: msg.contacts.map((ele) => ({ id: ele.phones[0]?.wa_id || ele.phones[0].phone, wa_id: ele.phones[0]?.wa_id || ele.phones[0].phone, name: (ele?.org?.company || '') +' '+ele.name.formatted_name })), + data: msg.contacts.map((ele) => ({ id: ele.phones[0]?.wa_id || ele.phones[0].phone, wa_id: ele.phones[0]?.wa_id || '', phone: ele.phones[0].phone, name: (ele?.org?.company || '') +' '+ele.name.formatted_name })), + waBtn: msg.contacts.some(ele => ele.phones.some(p => p.wa_id)), }), renderForReply: (msg) => ({ id: msg.wamid, diff --git a/src/views/Conversations/Components/MessagesList.jsx b/src/views/Conversations/Components/MessagesList.jsx index 8a48e9b..cac27f0 100644 --- a/src/views/Conversations/Components/MessagesList.jsx +++ b/src/views/Conversations/Components/MessagesList.jsx @@ -73,9 +73,15 @@ const MessagesList = ({ messages, handlePreview, reference, longListLoading, get return (
- {loadNextPage && messages.length>0 && ( + {loadNextPage && messages.length > 0 && (
- {!longListLoading ? : } + {!longListLoading ? ( + + ) : ( + + )}
)} {messages.map((message, index) => ( @@ -103,10 +109,14 @@ const MessagesList = ({ messages, handlePreview, reference, longListLoading, get {...(message.type === 'meetingLink' ? { actionButtons: [ - { - onClickButton: () => handleContactClick(message.data), - Component: () =>
发消息
, - }, + ...(message.waBtn + ? [ + { + onClickButton: () => handleContactClick(message.data), + Component: () =>
发消息
, + }, + ] + : []), { onClickButton: () => { navigator.clipboard.writeText(message.text);