在线窗口: 获取消息

dev/chat
Lei OT 2 years ago
parent 9c8a607d4a
commit f5e0c94032

@ -31,8 +31,7 @@ export const fetchMessages = async (params) => {
const defaultParams = { const defaultParams = {
opisn: '', opisn: '',
whatsappid: '', whatsappid: '',
// lasttime: '', lasttime: '',
lasttime: '2024-01-01T00:25:30', // test:
pagesize: MESSAGE_PAGE_SIZE, pagesize: MESSAGE_PAGE_SIZE,
}; };
const { errcode, result } = await fetchJSON(`${API_HOST}/getcusmessages`, {...defaultParams, ...params}); const { errcode, result } = await fetchJSON(`${API_HOST}/getcusmessages`, {...defaultParams, ...params});

@ -73,7 +73,7 @@ const Conversations = () => {
}; };
const getMessages = async (item) => { const getMessages = async (item) => {
setMsgLoading(true); setMsgLoading(true);
const data = await fetchMessages({ opisn: userId, whatsappid: item.whatsapp_phone_number, lasttime: '2024-01-01T00:25:30' }); const data = await fetchMessages({ opisn: userId, whatsappid: item.whatsapp_phone_number, lasttime: '' });
setMsgLoading(false); setMsgLoading(false);
receivedMessageList(item.sn, data); receivedMessageList(item.sn, data);
const thisLastTime = data.length > 0 ? data[data.length - 1].orgmsgtime : ''; const thisLastTime = data.length > 0 ? data[data.length - 1].orgmsgtime : '';

@ -25,7 +25,7 @@ const MessagesWrapper = () => {
const getMoreMessages = async () => { const getMoreMessages = async () => {
setShouldScrollBottom(false); setShouldScrollBottom(false);
setLongListLoading(true); setLongListLoading(true);
const data = await fetchMessages({ opisn: currentConversation.opi_sn, whatsappid: currentConversation.whatsapp_phone_number, lasttime: currentConversation?.lasttime || '2024-01-01T00:00:00' }); const data = await fetchMessages({ opisn: currentConversation.opi_sn, whatsappid: currentConversation.whatsapp_phone_number, lasttime: currentConversation?.lasttime || '' });
setLongListLoading(false); setLongListLoading(false);
setLongList(prevValue => data.concat(prevValue)); setLongList(prevValue => data.concat(prevValue));
const thisLastTime = data.length > 0 ? data[data.length - 1].orgmsgtime : ''; const thisLastTime = data.length > 0 ? data[data.length - 1].orgmsgtime : '';

Loading…
Cancel
Save