|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import { create } from 'zustand';
|
|
|
|
|
import { RealTimeAPI } from '@/channel/realTimeAPI';
|
|
|
|
|
import { olog, isEmpty, groupBy, sortArrayByOrder, pick, sortKeys, omit, sortObjectsByKeysMap } from '@/utils/commons';
|
|
|
|
|
import { olog, isEmpty, groupBy, sortArrayByOrder, pick, sortKeys, omit, sortObjectsByKeysMap, merge } from '@/utils/commons';
|
|
|
|
|
import { logWebsocket, clean7DaysWebsocketLog } from '@/utils/indexedDB'
|
|
|
|
|
import { receivedMsgTypeMapped, handleNotification } from '@/channel/bubbleMsgUtils';
|
|
|
|
|
import { fetchConversationsList, fetchTemplates, fetchConversationsSearch, UNREAD_MARK, fetchTags } from '@/actions/ConversationActions';
|
|
|
|
@ -278,13 +278,17 @@ const conversationSlice = (set, get) => ({
|
|
|
|
|
// 让当前会话显示在页面上
|
|
|
|
|
let _tmpCurrentMsgs = [];
|
|
|
|
|
if (currentConversation.sn) {
|
|
|
|
|
_tmpCurrentMsgs = activeConversations[currentConversation.sn];
|
|
|
|
|
// _tmpCurrentMsgs = activeConversations[currentConversation.sn];
|
|
|
|
|
}
|
|
|
|
|
const conversationsMapped = conversationsList.reduce((r, v) => ({ ...r, [`${v.sn}`]: [] }), {});
|
|
|
|
|
if (currentConversation.sn) {
|
|
|
|
|
const hasCurrent = Object.keys(conversationsMapped).findIndex(sn => Number(sn) === Number(currentConversation.sn)) !== -1;
|
|
|
|
|
conversationsMapped[currentConversation.sn] = _tmpCurrentMsgs;
|
|
|
|
|
const _len = hasCurrent ? 0 : conversationsList.unshift(currentConversation);
|
|
|
|
|
const indexCurrent = currentConversation.sn ? conversationsList.findIndex(ele => Number(ele.sn) === Number(currentConversation.sn)) : -1;
|
|
|
|
|
if (indexCurrent !== -1) {
|
|
|
|
|
const [currentElement] = conversationsList.splice(indexCurrent, 1);
|
|
|
|
|
conversationsList.unshift(currentElement); // Add to top
|
|
|
|
|
// const hasCurrent = Object.keys(conversationsMapped).findIndex(sn => Number(sn) === Number(currentConversation.sn)) !== -1;
|
|
|
|
|
// conversationsMapped[currentConversation.sn] = _tmpCurrentMsgs;
|
|
|
|
|
// conversationsList.unshift(hasCurrent ? )
|
|
|
|
|
// hasCurrent ? 0 : conversationsList.unshift(currentConversation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { topList, pageList } = sortConversationList(conversationsList);
|
|
|
|
@ -320,9 +324,11 @@ const conversationSlice = (set, get) => ({
|
|
|
|
|
const needUpdateCurrent = -1 !== newList.findIndex(row => Number(row.sn) === Number(currentConversation.sn));
|
|
|
|
|
const updateCurrent = needUpdateCurrent ? { currentConversation: newList.find(row => Number(row.sn) === Number(currentConversation.sn)) } : {};
|
|
|
|
|
// 让当前会话显示在页面上
|
|
|
|
|
if (currentConversation.sn) {
|
|
|
|
|
const hasCurrent = -1 !== Object.keys(mergedListMsgs).findIndex(sn => Number(sn) === Number(currentConversation.sn));
|
|
|
|
|
hasCurrent ? 0 : mergedList.unshift(currentConversation);
|
|
|
|
|
const indexCurrent = currentConversation.sn ? mergedList.findIndex(ele => Number(ele.sn) === Number(currentConversation.sn)) : -1;
|
|
|
|
|
if (indexCurrent !== -1 ) {
|
|
|
|
|
const [currentElement] = mergedList.splice(indexCurrent, 1);
|
|
|
|
|
mergedList.unshift(currentElement); // Add to top
|
|
|
|
|
// hasCurrent ? 0 : mergedList.unshift(currentConversation);
|
|
|
|
|
}
|
|
|
|
|
const refreshTotalNotify = mergedList.reduce((r, c) => r+(c.unread_msg_count === UNREAD_MARK ? 0 : c.unread_msg_count), 0);
|
|
|
|
|
|
|
|
|
|