perf: 当前会话: 使用会话ID,

2.0/email-builder
Lei OT 8 months ago
parent ff9f3e9118
commit eb8d59b2e8

@ -69,22 +69,37 @@ const Conversations = () => {
return () => {}; return () => {};
}, [conversationsList, listUpdateFlag, currentConversation.unread_msg_count]); }, [conversationsList, listUpdateFlag, currentConversation.unread_msg_count]);
const [switchToC, setSwitchToC] = useState({});
const [shouldFetchCList, setShouldFetchCList] = useState(true);
useEffect(() => { useEffect(() => {
if (order_sn && shouldFetchCList && initialState) { if (isEmpty(currentConversation.sn) && order_sn && shouldFetchCList && initialState) {
getOrderConversationList(order_sn); getOrderConversationList(order_sn)
} }
return () => {}; return () => {}
}, [order_sn, shouldFetchCList, initialState]); }, [conversationsList, initialState])
const [switchToC, setSwitchToC] = useState({});
const [shouldFetchCList, setShouldFetchCList] = useState(true);
// useEffect(() => {
// console.log('shouldFetchCList', order_sn , shouldFetchCList , initialState);
// if (order_sn && shouldFetchCList && initialState) {
// getOrderConversationList(order_sn);
// }
// return () => {};
// }, [order_sn, shouldFetchCList, initialState]);
const getOrderConversationList = async (colisn, WHATSAPP_ID = null) => { const getOrderConversationList = async (colisn, WHATSAPP_ID = null) => {
const { whatsapp_phone_number } = switchToC; const { whatsapp_phone_number } = switchToC;
const whatsappID = WHATSAPP_ID || coli_guest_WhatsApp || whatsapp_phone_number || ''; const whatsappID = WHATSAPP_ID || coli_guest_WhatsApp || whatsapp_phone_number || '';
// let findCurrentOrderChats = conversationsList.filter((item) => `${item.coli_sn}` === `${colisn}`); // let findCurrentOrderChats = conversationsList.filter((item) => `${item.coli_sn}` === `${colisn}`);
// 使opisn + whatsappID , whatsappID, // 使opisn + whatsappID , whatsappID,
let findCurrentOrderChats = conversationsList.filter((item) => `${item.whatsapp_phone_number}` === `${whatsappID}` && `${item.coli_sn}` === `${colisn}`); if (isEmpty(conversationsList)) {
return false;
}
let findCurrentOrderChats = conversationsList.filter((item) => `${item.whatsapp_phone_number}` === `${whatsappID}` && `${item.coli_sn}` === `${colisn}`)
let findCurrentIndex = isEmpty(findCurrentOrderChats) ? -1 : 0; // findCurrentOrderChats.length-1; let findCurrentIndex = isEmpty(findCurrentOrderChats) ? -1 : 0; // findCurrentOrderChats.length-1;
let findCurrent = findCurrentOrderChats[findCurrentIndex]; let findCurrent = findCurrentOrderChats[findCurrentIndex];
if (findCurrentIndex !== -1) { if (findCurrentIndex !== -1) {
@ -108,7 +123,7 @@ const Conversations = () => {
return findCurrent; return findCurrent;
} else { } else {
// reset chat window // reset chat window
setCurrentConversation({ sn: '', customer_name: '', coli_sn: order_sn }); // setCurrentConversation({ sn: '', customer_name: '', coli_sn: order_sn });
return false; return false;
} }
}; };

Loading…
Cancel
Save