From fed1594ddc734d36ab5d4e4f1aac49fd734a990d Mon Sep 17 00:00:00 2001 From: josc146 Date: Mon, 30 Oct 2023 21:09:23 +0800 Subject: [PATCH] fix stop button status of Chat page --- frontend/src/pages/Chat.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/pages/Chat.tsx b/frontend/src/pages/Chat.tsx index 53b6609..b5c9f1d 100644 --- a/frontend/src/pages/Chat.tsx +++ b/frontend/src/pages/Chat.tsx @@ -347,6 +347,8 @@ const ChatPanel: FC = observer(() => { onmessage(e) { scrollToBottom(); if (e.data.trim() === '[DONE]') { + if (answerId! in chatSseControllers) + delete chatSseControllers[answerId!]; commonStore.conversation[answerId!].done = true; commonStore.conversation[answerId!].content = commonStore.conversation[answerId!].content.trim(); commonStore.setConversation(commonStore.conversation); @@ -381,6 +383,8 @@ const ChatPanel: FC = observer(() => { console.log('Connection closed'); }, onerror(err) { + if (answerId! in chatSseControllers) + delete chatSseControllers[answerId!]; commonStore.conversation[answerId!].type = MessageType.Error; commonStore.conversation[answerId!].done = true; err = err.message || err;