|
|
|
@ -28,8 +28,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
|
|
|
|
|
|
|
|
|
|
const refreshTotalNotify = useConversationStore(useShallow((state) => state.refreshTotalNotify));
|
|
|
|
|
|
|
|
|
|
const [orderDetail] = useOrderStore(state => [state.orderDetail]);
|
|
|
|
|
|
|
|
|
|
const [orderDetail, ] = useOrderStore(state => [state.orderDetail, ]);
|
|
|
|
|
|
|
|
|
|
const isVisible = useVisibilityState();
|
|
|
|
|
|
|
|
|
@ -42,7 +41,15 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
|
|
|
|
|
}
|
|
|
|
|
setShouldScrollBottom(true);
|
|
|
|
|
return () => {};
|
|
|
|
|
}, [currentConversation.sn, orderDetail.coli_sn]);
|
|
|
|
|
}, [currentConversation.sn]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (currentConversation.sn) {
|
|
|
|
|
getFirstPageMessages({...currentConversation, });
|
|
|
|
|
}
|
|
|
|
|
setShouldScrollBottom(true);
|
|
|
|
|
return () => {};
|
|
|
|
|
}, [currentConversation.coli_sn]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setLongList(activeMessages);
|
|
|
|
@ -62,14 +69,19 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
|
|
|
|
|
}, [activeMessages.length, isVisible]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let refreshing = false;
|
|
|
|
|
const getFirstPageMessages = async (item) => {
|
|
|
|
|
if (refreshing !== false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
refreshing = true;
|
|
|
|
|
setMsgLoading(true);
|
|
|
|
|
const data = await fetchMessages({
|
|
|
|
|
conversationid: item.sn,
|
|
|
|
|
opisn: forceGetMessages ? currentConversation.opi_sn || '' : userId,
|
|
|
|
|
whatsappid: item.whatsapp_phone_number,
|
|
|
|
|
lasttime: '',
|
|
|
|
|
coli_sn: isEmpty(currentConversation.coli_sn) ? '' : (orderDetail.coli_sn || ''), // todo: 获取到上一个
|
|
|
|
|
coli_sn: currentConversation.coli_sn || '',
|
|
|
|
|
})
|
|
|
|
|
const thisLastTime = data.length > 0 ? data[0].msgtime : ''; // orgmsgtime
|
|
|
|
|
const loadNextPage = !(data.length === 0 || data.length < MESSAGE_PAGE_SIZE);
|
|
|
|
@ -77,6 +89,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
|
|
|
|
|
|
|
|
|
|
setMsgLoading(false);
|
|
|
|
|
receivedMessageList(item.sn, data);
|
|
|
|
|
refreshing = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getMoreMessages = async () => {
|
|
|
|
@ -87,7 +100,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
|
|
|
|
|
opisn: currentConversation.opi_sn,
|
|
|
|
|
whatsappid: currentConversation.whatsapp_phone_number,
|
|
|
|
|
lasttime: currentConversation?.lasttime || '',
|
|
|
|
|
coli_sn: isEmpty(currentConversation.coli_sn) ? '' : (orderDetail.coli_sn || ''),
|
|
|
|
|
coli_sn: currentConversation.coli_sn || '',
|
|
|
|
|
})
|
|
|
|
|
setLongListLoading(false);
|
|
|
|
|
setLongList(prevValue => data.concat(prevValue));
|
|
|
|
|