|
|
|
@ -106,26 +106,32 @@ const Conversations = () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// console.log('effect []');
|
|
|
|
|
if (mobile !== false) {
|
|
|
|
|
setCurrentConversation({});
|
|
|
|
|
} else
|
|
|
|
|
if (order_sn ) {
|
|
|
|
|
setCurrentConversation({ coli_sn: Number(order_sn), sn: null })
|
|
|
|
|
// updateCurrentConversation({ coli_sn: Number(order_sn) });
|
|
|
|
|
}
|
|
|
|
|
return () => {};
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (order_sn && shouldFetchCList) {
|
|
|
|
|
setCurrentConversation({ coli_sn: Number(order_sn) })
|
|
|
|
|
// updateCurrentConversation({ coli_sn: Number(order_sn) });
|
|
|
|
|
} else {
|
|
|
|
|
// setCurrentConversation({ coli_sn: order_sn })
|
|
|
|
|
}
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
// if (order_sn && shouldFetchCList) {
|
|
|
|
|
// setCurrentConversation({ coli_sn: Number(order_sn) })
|
|
|
|
|
// // updateCurrentConversation({ coli_sn: Number(order_sn) });
|
|
|
|
|
// } else {
|
|
|
|
|
// // setCurrentConversation({ coli_sn: order_sn })
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return () => {}
|
|
|
|
|
}, [order_sn])
|
|
|
|
|
// return () => {}
|
|
|
|
|
// }, [order_sn])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// console.log('effect isVisible', isVisible);
|
|
|
|
|
if (isVisible && initialState) {
|
|
|
|
|
refreshConversationList(new Date()); // 无感刷新, 不显示上面的loading,
|
|
|
|
|
}
|
|
|
|
@ -134,6 +140,7 @@ const Conversations = () => {
|
|
|
|
|
}, [isVisible]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// console.log('effect activeList');
|
|
|
|
|
if (isVisible && initialState) {
|
|
|
|
|
refreshConversationList(); // 显示loading
|
|
|
|
|
}
|
|
|
|
@ -150,15 +157,17 @@ const Conversations = () => {
|
|
|
|
|
setDataSource([...topList, ...pageList]);
|
|
|
|
|
// setDataSource(activeList ? conversationsList: closedConversationsList);
|
|
|
|
|
return () => {};
|
|
|
|
|
}, [conversationsList, listUpdateFlag, currentConversation.unread_msg_count]);
|
|
|
|
|
}, [conversationsList, topList, pageList, listUpdateFlag, currentConversation.unread_msg_count]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// console.log('effect get order c');
|
|
|
|
|
|
|
|
|
|
if (isEmpty(currentConversation.sn) && order_sn && shouldFetchCList && initialState) {
|
|
|
|
|
getOrderConversationList(order_sn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return () => {}
|
|
|
|
|
}, [order_sn, initialState, customerDetail.email])
|
|
|
|
|
}, [initialState, customerDetail.email])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getOrderConversationList = async (colisn) => {
|
|
|
|
@ -184,7 +193,7 @@ const Conversations = () => {
|
|
|
|
|
findCurrent = findCurrentOrderChats[findCurrentIndex];
|
|
|
|
|
|
|
|
|
|
if (findCurrentIndex !== -1) {
|
|
|
|
|
addToConversationList(findCurrentOrderChats);
|
|
|
|
|
addToConversationList(findCurrentOrderChats, 'top');
|
|
|
|
|
} else // if (!isEmpty(whatsappID))
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
@ -201,8 +210,8 @@ const Conversations = () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// else
|
|
|
|
|
if (isEmpty(whatsappID)) {
|
|
|
|
|
else {
|
|
|
|
|
// if (isEmpty(whatsappID) && findCurrentIndex === undefined) {
|
|
|
|
|
// 刷新页面
|
|
|
|
|
findCurrentIndex = conversationsList.findIndex((item) => `${item.coli_sn}` === `${colisn}`);
|
|
|
|
|
findCurrent = conversationsList[findCurrentIndex];
|
|
|
|
@ -219,6 +228,8 @@ const Conversations = () => {
|
|
|
|
|
|
|
|
|
|
const onSwitchConversation = async (item) => {
|
|
|
|
|
setCurrentConversation(item);
|
|
|
|
|
|
|
|
|
|
setShouldFetchCList(false);
|
|
|
|
|
if (isEmpty(item.coli_sn)) {
|
|
|
|
|
navigate(routePrefix, { replace: true });
|
|
|
|
|
} else {
|
|
|
|
@ -308,7 +319,7 @@ const Conversations = () => {
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<ChatListFilter
|
|
|
|
|
<ChatListFilter key='chat-list-filter'
|
|
|
|
|
onFilterChange={(d) => {
|
|
|
|
|
refreshConversationList()
|
|
|
|
|
}}
|
|
|
|
|