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