fix: 从订单页面进入会话页面.

dev/emitter
Lei OT 10 months ago
parent 70259d222e
commit 615f7b332f

@ -1,6 +1,6 @@
import { create } from 'zustand';
import { RealTimeAPI } from '@/channel/realTimeAPI';
import { olog, isEmpty, groupBy } from '@/utils/commons';
import { olog, isEmpty, groupBy, sortArrayByOrder } from '@/utils/commons';
import { receivedMsgTypeMapped, handleNotification } from '@/channel/bubbleMsgUtils';
import { fetchConversationsList, fetchTemplates, fetchConversationsSearch, UNREAD_MARK, fetchTags } from '@/actions/ConversationActions';
import { devtools } from 'zustand/middleware';
@ -299,9 +299,9 @@ const conversationSlice = (set, get) => ({
totalNotify: state.totalNotify - (conversation.unread_msg_count || 0),
currentConversation: Object.assign({}, conversation, targetItemFromList),
referenceMsg: {},
topList: mergedListMapped['1'] || [],
pageList: mergedListMapped['0'] || [],
conversationsList: [...conversationsList],
// topList: mergedListMapped['1'] || [],
// pageList: mergedListMapped['0'] || [],
// conversationsList: [...conversationsList],
}));
},
updateCurrentConversation: (conversation) => set((state) => ({ currentConversation: { ...state.currentConversation, ...conversation } })),

@ -55,13 +55,13 @@ export const useOrderStore = create(devtools((set, get) => ({
if (json.errcode === 0 && json.result.length > 0) {
const orderResult = json.result[0]
set(() => ({
orderDetail: orderResult,
orderDetail: {...orderResult, coli_sn: colisn },
customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {},
lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {},
quotationList: orderResult.quotes,
}))
return {
orderDetail: orderResult,
orderDetail: {...orderResult, coli_sn: colisn },
customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {},
lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {},
quotationList: orderResult.quotes,

@ -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()
}}

Loading…
Cancel
Save