订单会话: 刷新

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

@ -185,7 +185,7 @@ const conversationSlice = (set, get) => ({
unread_msg_count: 0,
}) : 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 { whatsapp_phone_number } = switchToC;
const whatsappID = coli_guest_WhatsApp || whatsapp_phone_number || '';
const data = await fetchOrderConversationsList({ opisn: userId, colisn: colisn, whatsappid: whatsappID });
if (!isEmpty(data)) {
addToConversationList(data);
let findCurrent = -1; // conversationsList.findIndex((item) => item.coli_sn === Number(colisn));
if (!isEmpty(whatsappID)) {
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);
ifCurrent = ifCurrent !== -1 ? ifCurrent : conversationsList.findIndex((item) => item.coli_sn === Number(colisn));
if (ifCurrent !== -1) {
switchConversation(conversationsList[ifCurrent === -1 ? 0 : ifCurrent]);
if (findCurrent !== -1) {
switchConversation(conversationsList[findCurrent]);
} else {
// reset chat window
setCurrentConversation({ sn: '', customer_name: '', coli_sn: order_sn });

Loading…
Cancel
Save