|
|
@ -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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|