diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index 0899bc3..2fcd47d 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -498,7 +498,7 @@ export const handleNotification = (title, _options) => { var notification; const options = { requireInteraction: true, // 设置手动关闭 - tag: 'global-sales-notification', // 通知ID,同类通知建议设置相同ID,避免通知过多遮挡桌面 + // tag: 'global-sales-notification', // 通知ID,同类通知建议设置相同ID,避免通知过多遮挡桌面 // icon: '/favicon.ico', // 通知图标 ..._options, }; diff --git a/src/views/Conversations/Components/ConversationsList.jsx b/src/views/Conversations/Components/ConversationsList.jsx index 84e3835..fa19402 100644 --- a/src/views/Conversations/Components/ConversationsList.jsx +++ b/src/views/Conversations/Components/ConversationsList.jsx @@ -69,26 +69,30 @@ const Conversations = () => { receivedMessageList(item.sn, data); }; const switchConversation = async (item) => { - fetchCleanUnreadMsgCount({ opisn: item.opi_sn, whatsappid: item.whatsapp_phone_number }); + setCurrentConversation(item); const messagesList = activeConversations[`${item.sn}`] || []; if (messagesList.length < 20) { getMessages(item); } - if (String(item.sn) === String(currentConversation.sn)) { - return false; - } - setCurrentConversation(item); }; const onSwitchConversation = async (item) => { - if (!isEmpty(item.coli_sn)) { + switchConversation(item); + if (isEmpty(item.coli_sn)) { + navigate(`/order/chat`, { replace: true }); + } else { setSwitchToC(item); setShouldFetchCList(false); navigate(`/order/chat/${item.coli_sn}`, { replace: true }); - } else { - navigate(`/order/chat`, { replace: true }); } - switchConversation(item); + // if (!isEmpty(item.coli_sn)) { + // setSwitchToC(item); + // setShouldFetchCList(false); + // navigate(`/order/chat/${item.coli_sn}`, { replace: true }); + // } else { + // navigate(`/order/chat`, { replace: true }); + // } + // switchConversation(item); }; const handleConversationItemClose = async (item) => { diff --git a/src/views/Conversations/Components/MessagesWrapper.jsx b/src/views/Conversations/Components/MessagesWrapper.jsx index 84b1323..e99265b 100644 --- a/src/views/Conversations/Components/MessagesWrapper.jsx +++ b/src/views/Conversations/Components/MessagesWrapper.jsx @@ -1,12 +1,23 @@ -import { useRef, useState } from 'react'; +import { useRef, useState, useEffect } from 'react'; import useConversationStore from '@/stores/ConversationStore'; import { useShallow } from 'zustand/react/shallow'; import { Image, } from 'antd'; import MessagesList from './MessagesList'; +import { fetchCleanUnreadMsgCount } from '@/actions/ConversationActions'; const MessagesWrapper = () => { + const currentConversation = useConversationStore(useShallow((state) => state.currentConversation)); const activeMessages = useConversationStore(useShallow((state) => (state.currentConversation.sn && state.activeConversations[state.currentConversation.sn] ? state.activeConversations[state.currentConversation.sn]: []))); + useEffect(() => { + if (currentConversation.opi_sn && currentConversation.whatsapp_phone_number && activeMessages.length > 0) { + fetchCleanUnreadMsgCount({ opisn: currentConversation.opi_sn, whatsappid: currentConversation.whatsapp_phone_number }); + } + + return () => {}; + }, [activeMessages]); + + const reference = useRef(null); const [previewVisible, setPreviewVisible] = useState(false);