根据类型, 控制是否允许引用

dev/chat
Lei OT 2 years ago
parent bb3168169c
commit 662b614b60

@ -212,6 +212,7 @@ export const parseRenderMessageItem = (msg) => {
customer_name: msg?.customerProfile?.name || '', customer_name: msg?.customerProfile?.name || '',
whatsapp_name: msg?.customerProfile?.name || '', whatsapp_name: msg?.customerProfile?.name || '',
whatsapp_phone_number: msg.from, whatsapp_phone_number: msg.from,
whatsapp_msg_type: msg.type,
}; };
}; };
/** /**
@ -240,6 +241,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
: {}), : {}),
// conversationid: conversationid, // conversationid: conversationid,
// title: msg.customerProfile.name, // title: msg.customerProfile.name,
whatsapp_msg_type: msgContent.type,
}; };
}); });
}; };

@ -70,10 +70,12 @@ const ConversationReducer = (state = initialState, action) => {
const message = action.payload; const message = action.payload;
const targetId = message.conversationid; const targetId = message.conversationid;
const targetMsgs = (activeConversations[String(targetId)] || []).map((ele) => { const targetMsgs = (activeConversations[String(targetId)] || []).map((ele) => {
// 更新状态
// * 已读的不再更新状态, 有时候投递结果在已读之后返回
if (ele.id === ele.actionId && ele.actionId === message.actionId) { if (ele.id === ele.actionId && ele.actionId === message.actionId) {
return { ...ele, id: message.id, status: message.status, dateString: message.dateString }; return { ...ele, id: message.id, status: ele.status === 'read' ? ele.status : message.status, dateString: message.dateString };
} else if (ele.id === message.id) { } else if (ele.id === message.id) {
return { ...ele, id: message.id, status: message.status, dateString: message.dateString }; return { ...ele, id: message.id, status: ele.status === 'read' ? ele.status : message.status, dateString: message.dateString };
} }
return ele; return ele;
}); });

@ -102,15 +102,15 @@ const Conversations = () => {
}; };
const switchConversation = async (item) => { const switchConversation = async (item) => {
console.log('invoke switch'); console.log('invoke switch');
if (String(item.sn) === String(currentConversation.sn)) {
return false;
}
dispatch(setCurrentConversation(item));
const messagesList = activeConversations[`${item.sn}`] || []; const messagesList = activeConversations[`${item.sn}`] || [];
if (isEmpty(messagesList)) { if (isEmpty(messagesList)) {
const data = await fetchMessages({ opisn: userId, whatsappid: item.whatsapp_phone_number }); const data = await fetchMessages({ opisn: userId, whatsappid: item.whatsapp_phone_number });
dispatch(receivedMessageList(item.sn, data)); dispatch(receivedMessageList(item.sn, data));
} }
if (String(item.sn) === String(currentConversation.sn)) {
return false;
}
dispatch(setCurrentConversation(item));
}; };
const onSwitchConversation = (item) => { const onSwitchConversation = (item) => {

@ -48,12 +48,12 @@ const Messages = () => {
notchStyle: { fill: '#ccd5ae' }, notchStyle: { fill: '#ccd5ae' },
// forwarded: false, // forwarded: false,
// todo: reaction: emoji // todo: reaction: emoji
replyButton: message.type === 'text' && message.status !== 'failed' ? true : false, replyButton: ['text'].includes(message.whatsapp_msg_type) && message.status !== 'failed' ? true : false,
onReplyClick: () => dispatch(setReplyTo(message)), onReplyClick: () => dispatch(setReplyTo(message)),
className: 'whatsappme-container whitespace-pre-wrap', className: 'whatsappme-container whitespace-pre-wrap',
} }
: { : {
replyButton: message.type === 'text' ? true : false, replyButton: ['text'].includes(message.whatsapp_msg_type) ? true : false,
onReplyClick: () => dispatch(setReplyTo(message)), onReplyClick: () => dispatch(setReplyTo(message)),
})} })}
// notchStyle={{fill: '#ccd5ae'}} // notchStyle={{fill: '#ccd5ae'}}

Loading…
Cancel
Save