From ae093ae0ad07ec6c22a6817c0c0f4118558941f3 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 16 May 2022 16:46:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BB=8E=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/redux/slices/chat.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shared/redux/slices/chat.ts b/shared/redux/slices/chat.ts index 1a5097a8..44758c0b 100644 --- a/shared/redux/slices/chat.ts +++ b/shared/redux/slices/chat.ts @@ -43,10 +43,12 @@ const chatSlice = createSlice({ setConverseInfo(state, action: PayloadAction) { const converseId = action.payload._id; + const originInfo = state.converses[converseId] + ? { ...state.converses[converseId] } + : { messages: [], hasFetchedHistory: false, hasMoreMessage: true }; + state.converses[converseId] = { - messages: [], - hasFetchedHistory: false, - hasMoreMessage: true, + ...originInfo, ...action.payload, }; },