perf: WhatsApp消息显示接收的对象

todo: 引用消息时账户处理
dev/emitter
Lei OT 10 months ago
parent 1af713fa45
commit d87de856be

@ -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: '',
}),
}
});
};

@ -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 (
<span className={`text-sm leading-5 emoji-text whitespace-pre-wrap ${className} ${extraClass}`} key={'msg-text'}>
{headerObj ? (
@ -77,12 +75,6 @@ const BubbleIM = ({ handlePreview, handleContactClick, setNewChatModalVisible, s
}
})}
{footerObj ? <div className=' text-neutral-500'>{footerObj.text}</div> : null}
{receivedMsgFooter ? (
<div className='text-right border-0 pt-[2px] border-t-slate-200 border-t border-solid text-xs text-neutral-500'>
<ChannelLogo channel={message.msg_source} className='text-xs w-3 h-3 ' />
<span className='italic'>{receivedMsgFooter}</span>
</div>
) : null}
{buttonsArr && buttonsArr.length > 0 ? (
<div className='flex flex-row gap-1'>
{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: <><ChannelLogo channel={message.msg_source} />&nbsp;{WABAccountsMapped[message.from]?.verifiedName}</>,
title: <><ChannelLogo channel={message.msg_source} />&nbsp;{message.wabaName}</>,
}
: {
// title: <>&nbsp;<ChannelLogo channel={message.msg_source} />&nbsp;{message.title}</>,
dateString: `${message.wabaName} - ${message.dateString}`,
})}
className={[
'whitespace-pre-wrap',

@ -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])

Loading…
Cancel
Save