From 86a7d764097dd56f7003f22b132391780a020382 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 18 Dec 2024 10:32:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=9A=84=E4=BC=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Online/ConversationsList.jsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/views/Conversations/Online/ConversationsList.jsx b/src/views/Conversations/Online/ConversationsList.jsx index 5df8e4c..94791b1 100644 --- a/src/views/Conversations/Online/ConversationsList.jsx +++ b/src/views/Conversations/Online/ConversationsList.jsx @@ -7,7 +7,7 @@ import ConversationsNewItem from './ConversationsNewItem'; import { debounce, flush, isEmpty, isNotEmpty, pick } from '@/utils/commons'; import useConversationStore from '@/stores/ConversationStore'; import useAuthStore from '@/stores/AuthStore'; -import { useOrderStore, OrderLabelDefaultOptions, OrderStatusDefaultOptions } from "@/stores/OrderStore"; +// import { useOrderStore, OrderLabelDefaultOptions, OrderStatusDefaultOptions } from "@/stores/OrderStore"; import { useVisibilityState } from '@/hooks/useVisibilityState'; import ChatListItem from './Components/ChatListItem'; import ChatListFilter from './Components/ChatListFilter'; @@ -25,14 +25,14 @@ const Conversations = () => { const routerReplace = mobile === false ? true : false; // : true; const routePrefix = mobile === false ? `/order/chat` : `/m/chat`; const { state: orderRow } = useLocation(); - const { coli_guest_WhatsApp } = orderRow || {}; + const { coli_guest_WhatsApp, guest_email } = orderRow || {}; const { order_sn } = useParams(); const navigate = useNavigate(); const userId = useAuthStore((state) => state.loginUser.userId); const initialState = useConversationStore((state) => state.initialState); - const [customerDetail] = useOrderStore((s) => [s.customerDetail]) + // const [customerDetail] = useOrderStore((s) => [s.customerDetail]) const [currentConversation, setCurrentConversation, updateCurrentConversation] = useConversationStore((state) => [state.currentConversation, state.setCurrentConversation, state.updateCurrentConversation]); const [topList, pageList, conversationsList] = useConversationStore((state) => [state.topList, state.pageList, state.conversationsList]); @@ -162,12 +162,14 @@ const Conversations = () => { let orderChatRefreshing = false; useEffect(() => { - if (isEmpty(currentConversation.sn) && order_sn && shouldFetchCList && initialState) { + // console.log('first', isEmpty(currentConversation.sn) , order_sn , shouldFetchCList , initialState) + // isEmpty(currentConversation.sn) && + if (order_sn && shouldFetchCList && initialState) { getOrderConversationList(order_sn) } return () => {} - }, [initialState, customerDetail]) + }, [order_sn, shouldFetchCList, initialState]) const getOrderConversationList = async (colisn) => { @@ -178,6 +180,7 @@ const Conversations = () => { const { whatsapp_phone_number } = switchToC; const whatsappID = coli_guest_WhatsApp || whatsapp_phone_number || ''; + const _email = guest_email || ''; // if (isEmpty(conversationsList)) { // return false; // } @@ -188,10 +191,10 @@ const Conversations = () => { // let findCurrentOrderChats = conversationsList.filter((item) => `${item.coli_sn}` === `${colisn}`); // 使用opisn + whatsappID 判断, 解决订单修改whatsappID号码之后获取新会话, 登录账号此处省略 - if (!isEmpty(whatsappID) || !isEmpty(customerDetail.email)) { + if (!isEmpty(whatsappID) || !isEmpty(_email)) { findCurrentOrderChats = conversationsList.filter( - (item) => `${item.coli_sn}` === `${colisn}` && (`${item.whatsapp_phone_number}` === `${whatsappID}` || `${item.channels?.email}` === `${customerDetail.email}`) + (item) => `${item.coli_sn}` === `${colisn}` && (`${item.whatsapp_phone_number}` === `${whatsappID}` || `${item.channels?.email}` === `${_email}`) ) findCurrentIndex = isEmpty(findCurrentOrderChats) ? -1 : 0; // findCurrentOrderChats.length-1; findCurrent = findCurrentOrderChats[findCurrentIndex]; @@ -201,7 +204,8 @@ const Conversations = () => { } else // if (!isEmpty(whatsappID)) { try { - const data = await fetchOrderConversationsList({ opisn: userId, colisn: colisn, whatsappid: whatsappID, email: customerDetail.email }); + setShouldFetchCList(false); + const data = await fetchOrderConversationsList({ opisn: userId, colisn: colisn, whatsappid: whatsappID, email: _email }); if (!isEmpty(data)) { addToConversationList(data); findCurrentIndex = 0; // data.length-1; // data.lastIndexOf((item) => item.coli_sn === Number(colisn));