From ede92014c1d07c9b0812542b219dc5ecf7283645 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 24 May 2024 16:49:02 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=96=B0=E6=B6=88=E6=81=AF:=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=9A=E8=AF=9D=E5=88=97=E8=A1=A8:=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A4=E6=96=AD;=20console?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/ConversationStore.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/stores/ConversationStore.js b/src/stores/ConversationStore.js index 353c9f5..724ffe1 100644 --- a/src/stores/ConversationStore.js +++ b/src/stores/ConversationStore.js @@ -307,7 +307,7 @@ const messageSlice = (set, get) => ({ // msgRender: const { activeConversations, conversationsList, currentConversation, totalNotify } = get(); const targetMsgs = activeConversations[String(targetId)] || []; - const targetIndex = conversationsList.findIndex((ele) => String(ele.sn) === String(targetId)); + const targetIndex = conversationsList.findIndex((ele) => Number(ele.sn) === Number(targetId)); const lastReceivedTime = (message.type !== 'system' && message.sender !== 'me') ? dayjs(message.date).add(8, 'hours').format(DATETIME_FORMAT) : null; const newConversation = targetIndex !== -1 @@ -315,7 +315,7 @@ const messageSlice = (set, get) => ({ ...conversationsList[targetIndex], last_received_time: lastReceivedTime || conversationsList[targetIndex].last_received_time, unread_msg_count: - String(targetId) !== String(currentConversation.sn) && message.sender !== 'me' + Number(targetId) !== Number(currentConversation.sn) && message.sender !== 'me' ? conversationsList[targetIndex].unread_msg_count + 1 : conversationsList[targetIndex].unread_msg_count, } @@ -332,6 +332,8 @@ const messageSlice = (set, get) => ({ }; conversationsList.splice(targetIndex, 1); conversationsList.unshift(newConversation); + console.log('find in list, i:', targetIndex); + console.log('find in list, chat updated and Top: \n', JSON.stringify(newConversation, null, 2)); const isCurrent = Number(targetId) === Number(currentConversation.sn); const updatedCurrent = isCurrent ? { @@ -345,9 +347,9 @@ const messageSlice = (set, get) => ({ console.log('is current and update', isCurrent, JSON.stringify(updatedCurrent, null, 2)); return set({ currentConversation: updatedCurrent, + conversationsList: [...conversationsList], totalNotify: totalNotify + (message.sender === 'me' ? 0 : 1), activeConversations: { ...activeConversations, [String(targetId)]: [...targetMsgs, message] }, - conversationsList: [...conversationsList], }); }, });