新消息, 滚动

dev/chat
Lei OT 1 year ago
parent d07848a401
commit 0c0b197439

@ -90,18 +90,15 @@ const Conversations = () => {
}
};
const switchConversation = async (item) => {
if (currentConversation.sn === item.sn) {
return false;
}
dispatch(setCurrentConversation(item));
if (isEmpty(item.coli_sn) || item.coli_sn === '0') {
dispatch(receivedCustomerProfile({}));
}
const messagesList = activeConversations[`${item.sn}`] || [];
if (isEmpty(messagesList)) {
const data = await fetchMessages({ opisn: userId, whatsappid: item.whatsapp_phone_number });
dispatch(receivedMessageList(item.sn, data));
}
if (isEmpty(item.coli_sn) || item.coli_sn === '0') {
dispatch(receivedCustomerProfile({}));
}
};
const onSwitchConversation = (item) => {

@ -1,11 +1,12 @@
import { useEffect, useState, useRef } from 'react';
import { useEffect, useState, useRef, useMemo } from 'react';
import { Image, Alert } from 'antd';
import { MessageBox } from 'react-chat-elements';
import { useConversationState } from '@/stores/ConversationContext';
const Messages = () => {
const { activeConversations, currentConversation } = useConversationState();
const messagesList = activeConversations[currentConversation.sn] || [];
const messagesList = useMemo(() => activeConversations[currentConversation.sn] || [], [activeConversations, currentConversation.sn]);
console.log('messagesList----------------------------------------------------', messagesList);
const messagesEndRef = useRef(null);

Loading…
Cancel
Save