|
|
|
@ -7,26 +7,25 @@ import { fetchCleanUnreadMsgCount, fetchMessages, MESSAGE_PAGE_SIZE } from '@/ac
|
|
|
|
|
import useAuthStore from '@/stores/AuthStore';
|
|
|
|
|
import { useVisibilityState } from '@/hooks/useVisibilityState';
|
|
|
|
|
import ConversationNewItem from './ConversationsNewItem';
|
|
|
|
|
import emailItem from './Components/emailSent.json';
|
|
|
|
|
import emailReItem from './Components/emailRe.json';
|
|
|
|
|
// import EmailEditor from './Input/bak/EmailEditor';
|
|
|
|
|
import EmailEditorPopup from './Input/EmailEditorPopup';
|
|
|
|
|
import EmailDetail from './Components/EmailDetail';
|
|
|
|
|
import { useOrderStore, } from "@/stores/OrderStore";
|
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
|
|
|
|
|
|
const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
|
|
|
|
|
const userId = useAuthStore((state) => state.loginUser.userId);
|
|
|
|
|
|
|
|
|
|
const [currentConversation, updateCurrentConversation, setCurrentConversation] = useConversationStore((state) => [state.currentConversation, state.updateCurrentConversation, state.setCurrentConversation]);
|
|
|
|
|
const conversationsList = useConversationStore((state) => state.conversationsList);
|
|
|
|
|
// const conversationsList = useConversationStore((state) => state.conversationsList);
|
|
|
|
|
const activeMessages = useConversationStore(useShallow((state) => (state.currentConversation.sn && state.activeConversations[state.currentConversation.sn] ? state.activeConversations[state.currentConversation.sn]: [])));
|
|
|
|
|
const addToConversationList = useConversationStore((state) => state.addToConversationList);
|
|
|
|
|
// const addToConversationList = useConversationStore((state) => state.addToConversationList);
|
|
|
|
|
|
|
|
|
|
const receivedMessageList = useConversationStore((state) => state.receivedMessageList);
|
|
|
|
|
const setMsgLoading = useConversationStore((state) => state.setMsgLoading);
|
|
|
|
|
|
|
|
|
|
const refreshTotalNotify = useConversationStore(useShallow((state) => state.refreshTotalNotify));
|
|
|
|
|
const currentConversationSN = useConversationStore(useShallow((state) => state.currentConversation.sn));
|
|
|
|
|
const currentConversationColiSN = useConversationStore(useShallow((state) => state.currentConversation.coli_sn));
|
|
|
|
|
|
|
|
|
|
const [orderDetail, ] = useOrderStore(state => [state.orderDetail, ]);
|
|
|
|
|
|
|
|
|
@ -35,21 +34,32 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
|
|
|
|
|
const [longList, setLongList] = useState([]);
|
|
|
|
|
const [longListLoading, setLongListLoading] = useState(false);
|
|
|
|
|
const [shouldScrollBottom, setShouldScrollBottom] = useState(true);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
return () => {
|
|
|
|
|
setCurrentConversation({})
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (currentConversation.sn && (activeMessages.length < 20 || forceGetMessages !== undefined)) {
|
|
|
|
|
// console.log('effect sn', currentConversationSN);
|
|
|
|
|
|
|
|
|
|
if (currentConversationSN && (activeMessages.length < 20 || forceGetMessages !== undefined)) {
|
|
|
|
|
getFirstPageMessages(currentConversation);
|
|
|
|
|
}
|
|
|
|
|
setShouldScrollBottom(true);
|
|
|
|
|
return () => {};
|
|
|
|
|
}, [currentConversation.sn]);
|
|
|
|
|
}, [currentConversationSN]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// console.log('effect coli_sn', currentConversationSN);
|
|
|
|
|
|
|
|
|
|
if (currentConversation.sn) {
|
|
|
|
|
getFirstPageMessages({...currentConversation, });
|
|
|
|
|
}
|
|
|
|
|
setShouldScrollBottom(true);
|
|
|
|
|
return () => {};
|
|
|
|
|
}, [currentConversation.coli_sn]);
|
|
|
|
|
}, [currentConversationColiSN]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setLongList(activeMessages);
|
|
|
|
|