perf(前端): 发出的消息, 无状态则显示为`等待`

dev/supplier-email-drawer
Lei OT 9 months ago
parent 11e876ef5a
commit 5c023c8b45

@ -322,7 +322,7 @@ const whatsappMsgMapped = {
...msgcontent, ...msgcontent,
...parseRenderMessageItem(msgcontent), ...parseRenderMessageItem(msgcontent),
id: msgcontent.wamid, id: msgcontent.wamid,
status: msgStatusRenderMapped[msgcontent?.status || 'failed'], status: msgStatusRenderMapped[msgcontent?.status || 'accepted'],
sender: 'me', sender: 'me',
dateString: msgcontent.status === 'failed' ? `发送失败 ${whatsappError?.[msgcontent.errorCode] || msgcontent.errorMessage || ''}` : '', dateString: msgcontent.status === 'failed' ? `发送失败 ${whatsappError?.[msgcontent.errorCode] || msgcontent.errorMessage || ''}` : '',
}), }),
@ -369,7 +369,7 @@ const whatsappMsgMapped = {
...msgcontent, ...msgcontent,
...parseRenderMessageItem(msgcontent), ...parseRenderMessageItem(msgcontent),
id: msgcontent.wamid, id: msgcontent.wamid,
status: msgcontent.msg_direction === 'outbound' ? msgStatusRenderMapped[msgcontent?.status || 'failed'] : '', status: msgcontent.msg_direction === 'outbound' ? msgStatusRenderMapped[msgcontent?.status || 'accepted'] : '',
sender: msgcontent.msg_direction === 'outbound' ? 'me' : msgcontent?.customerProfile?.name || '', sender: msgcontent.msg_direction === 'outbound' ? 'me' : msgcontent?.customerProfile?.name || '',
dateString: msgcontent.status === 'failed' ? `发送失败 ❌` : '', dateString: msgcontent.status === 'failed' ? `发送失败 ❌` : '',
}), }),
@ -419,7 +419,7 @@ const emailMsgMapped = {
...msgcontent, ...msgcontent,
...parseRenderMessageItem({...msgcontent, }), ...parseRenderMessageItem({...msgcontent, }),
id: msgcontent.id, id: msgcontent.id,
status: msgStatusRenderMapped[(msgcontent?.status || 'failed')], status: msgStatusRenderMapped[(msgcontent?.status || 'accepted')],
sender: 'me', sender: 'me',
dateString: msgcontent.status==='failed' ? `发送失败 ❌` : '', dateString: msgcontent.status==='failed' ? `发送失败 ❌` : '',
}), }),
@ -467,7 +467,7 @@ export const receivedMsgTypeMapped = {
...msgcontent, ...msgcontent,
actionId: msgcontent.actionId, actionId: msgcontent.actionId,
id: msgcontent.wamid, id: msgcontent.wamid,
status: msgStatusRenderMapped[(msgcontent?.status || 'failed')], status: msgStatusRenderMapped[(msgcontent?.status || 'accepted')],
conversationid: msgcontent.actionId.split('.')[0], // msgcontent.conversation.sn, conversationid: msgcontent.actionId.split('.')[0], // msgcontent.conversation.sn,
date: msgcontent.createTime, date: msgcontent.createTime,
sender: 'me', sender: 'me',
@ -735,9 +735,9 @@ export const parseRenderMessageItem = (msg) => {
whatsapp_phone_number: isEmpty(msg?.customerProfile) ? msg.to : msg.from, whatsapp_phone_number: isEmpty(msg?.customerProfile) ? msg.to : msg.from,
// whatsapp_msg_type: msg.msg_source==='WABA' ? msg.type : '', // whatsapp_msg_type: msg.msg_source==='WABA' ? msg.type : '',
// whatsapp_msg_type: (msg.msg_source || 'WABA') === 'WABA' ? msg.type : '', // 1.0接口没有msg_source // whatsapp_msg_type: (msg.msg_source || 'WABA') === 'WABA' ? msg.type : '', // 1.0接口没有msg_source
statusCN: msgStatusRenderMappedCN[msg?.status || 'failed'], statusCN: msgStatusRenderMappedCN[msg?.status || 'accepted'],
statusTitle: msgStatusRenderMappedCN[msg?.status || 'failed'], statusTitle: msgStatusRenderMappedCN[msg?.status || 'accepted'],
replyButton: !['waiting', 'failed'].includes(msg?.status || '') , replyButton: !['accepted', 'waiting', 'failed'].includes(msg?.status || '') ,
...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true // || isEmpty(msg.messageorigin) ...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true // || isEmpty(msg.messageorigin)
? {} ? {}
: { : {
@ -789,7 +789,7 @@ export const parseRenderMessageList = (messages) => {
msgContent.template = msg.msgtype === 'template' ? { ...msgContent.template, ...template } : {}; msgContent.template = msg.msgtype === 'template' ? { ...msgContent.template, ...template } : {};
// const parseMethod = msgContent.bizType === 'whatsapp' ? cloneDeep(whatsappMsgTypeMapped) : {}; // const parseMethod = msgContent.bizType === 'whatsapp' ? cloneDeep(whatsappMsgTypeMapped) : {};
let waCode, waError = ''; let waCode, waError = '';
if ((msgContent?.status || 'failed') === 'failed' && msgContent.errorMessage && msg.msg_direction === 'outbound') { if ((msgContent?.status || 'accepted') === 'failed' && msgContent.errorMessage && msg.msg_direction === 'outbound') {
(waCode = msgContent.errorMessage.match(/\(#(\d+)\)/)); (waCode = msgContent.errorMessage.match(/\(#(\d+)\)/));
(waError = (whatsappError?.[waCode?.[1]] || whatsappError?.[msgContent.errorCode] || msgContent.errorMessage)); (waError = (whatsappError?.[waCode?.[1]] || whatsappError?.[msgContent.errorCode] || msgContent.errorMessage));
if (!isEmpty(msgContent.whatsappApiError)) { if (!isEmpty(msgContent.whatsappApiError)) {
@ -816,20 +816,20 @@ export const parseRenderMessageList = (messages) => {
from: msgContent.from, from: msgContent.from,
sender: msgContent.from, sender: msgContent.from,
senderName: msgContent?.customerProfile?.name || msgContent.from || 'me', senderName: msgContent?.customerProfile?.name || msgContent.from || 'me',
replyButton: !['waiting', 'failed'].includes(msgContent?.status || '') , replyButton: !['accepted', 'waiting', 'failed'].includes(msgContent?.status || '') ,
// 用forwarded表示Resend, 与Reply互斥 // 用forwarded表示Resend, 与Reply互斥
forwarded: msg.msg_direction === 'outbound' && msg.msg_source === 'email' && ['email'].includes(msgContent.type) && (msgContent?.status || 'failed') === 'failed', forwarded: msg.msg_direction === 'outbound' && msg.msg_source === 'email' && ['email'].includes(msgContent.type) && (msgContent?.status || 'accepted') === 'failed',
...(msg.msg_direction === 'outbound' ...(msg.msg_direction === 'outbound'
? { ? {
sender: 'me', sender: 'me',
senderName: 'me', senderName: 'me',
status: msgStatusRenderMapped[msgContent?.status || 'failed'], status: msgStatusRenderMapped[msgContent?.status || 'accepted'],
dateString: msgStatusRenderMapped[msgContent?.status || 'failed'] === 'failed' ? `${(msg.msgtime || '').replace('T', ' ')} 发送失败 ${waError}` : '', dateString: msgStatusRenderMapped[msgContent?.status || 'accepted'] === 'failed' ? `${(msg.msgtime || '').replace('T', ' ')} 发送失败 ${waError}` : '',
statusCN: msgStatusRenderMappedCN[msgContent?.status || 'failed'], statusCN: msgStatusRenderMappedCN[msgContent?.status || 'accepted'],
statusTitle: msgStatusRenderMappedCN[msgContent?.status || 'failed'], statusTitle: msgStatusRenderMappedCN[msgContent?.status || 'accepted'],
id: (msgContent?.status || 'failed') === 'failed' ? (msgContent.actionId || msgContent.id) : (msgTypeData.id || msg.id || msg.sn), id: (msgContent?.status || 'accepted') === 'failed' ? (msgContent.actionId || msgContent.id) : (msgTypeData.id || msg.id || msg.sn),
actionId: msgContent.actionId, actionId: msgContent.actionId,
replyButton: !['waiting', 'failed'].includes(msgContent?.status || 'failed') , replyButton: !['accepted', 'waiting', 'failed'].includes(msgContent?.status || 'accepted') ,
} }
: {}), : {}),
...(isEmpty(messageorigin) && (isEmpty(msgContent.context) || msgContent.context?.forwarded === true) ...(isEmpty(messageorigin) && (isEmpty(msgContent.context) || msgContent.context?.forwarded === true)

Loading…
Cancel
Save