读取到消息之后, 未读清零

dev/chat
Lei OT 1 year ago
parent 0ddf156761
commit 99d95b90b2

@ -70,7 +70,6 @@ const Conversations = () => {
};
const switchConversation = async (item) => {
setCurrentConversation(item);
fetchCleanUnreadMsgCount({ opisn: item.opi_sn, whatsappid: item.whatsapp_phone_number });
const messagesList = activeConversations[`${item.sn}`] || [];
if (messagesList.length < 20) {
getMessages(item);

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

Loading…
Cancel
Save