订单会话: 刷新

dev/chat
Lei OT 2 years ago
parent 65a9095b0d
commit 38e18cf4b8

@ -185,7 +185,7 @@ const conversationSlice = (set, get) => ({
unread_msg_count: 0, unread_msg_count: 0,
}) : null; }) : null;
return set({ totalNotify: totalNotify - conversation.unread_msg_count, currentConversation: conversation, referenceMsg: {}, conversationsList: [...conversationsList] }); return set({ totalNotify: totalNotify - (conversation.unread_msg_count || 0), currentConversation: conversation, referenceMsg: {}, conversationsList: [...conversationsList] });
}, },
}); });

@ -40,14 +40,16 @@ const Conversations = () => {
const getOrderConversationList = async (colisn) => { const getOrderConversationList = async (colisn) => {
const { whatsapp_phone_number } = switchToC; const { whatsapp_phone_number } = switchToC;
const whatsappID = coli_guest_WhatsApp || whatsapp_phone_number || ''; const whatsappID = coli_guest_WhatsApp || whatsapp_phone_number || '';
const data = await fetchOrderConversationsList({ opisn: userId, colisn: colisn, whatsappid: whatsappID }); let findCurrent = -1; // conversationsList.findIndex((item) => item.coli_sn === Number(colisn));
if (!isEmpty(data)) { if (!isEmpty(whatsappID)) {
addToConversationList(data); const data = await fetchOrderConversationsList({ opisn: userId, colisn: colisn, whatsappid: whatsappID });
if (!isEmpty(data)) {
addToConversationList(data);
}
findCurrent = conversationsList.findIndex((item) => item.coli_sn === Number(colisn)); // data.findIndex((item) => item.sn === currentConversation.sn);
} }
let ifCurrent = data.findIndex((item) => item.sn === currentConversation.sn); if (findCurrent !== -1) {
ifCurrent = ifCurrent !== -1 ? ifCurrent : conversationsList.findIndex((item) => item.coli_sn === Number(colisn)); switchConversation(conversationsList[findCurrent]);
if (ifCurrent !== -1) {
switchConversation(conversationsList[ifCurrent === -1 ? 0 : ifCurrent]);
} else { } else {
// reset chat window // reset chat window
setCurrentConversation({ sn: '', customer_name: '', coli_sn: order_sn }); setCurrentConversation({ sn: '', customer_name: '', coli_sn: order_sn });

Loading…
Cancel
Save