From 5372c48f53eb9f0c0e72ec4d0b109236a007777d Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Mon, 6 Mar 2023 22:36:36 +0800 Subject: [PATCH] fix migration from old to new ChatInterface --- src/components/Chat/ChatContent/ChatTitle.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/Chat/ChatContent/ChatTitle.tsx b/src/components/Chat/ChatContent/ChatTitle.tsx index b8f3691..96c3c85 100644 --- a/src/components/Chat/ChatContent/ChatTitle.tsx +++ b/src/components/Chat/ChatContent/ChatTitle.tsx @@ -30,10 +30,9 @@ const ChatTitle = React.memo(() => { // for migrating from old ChatInterface to new ChatInterface (with config) useEffect(() => { - if (!config) { - const updatedChats: ChatInterface[] = JSON.parse( - JSON.stringify(useStore.getState().chats) - ); + const chats = useStore.getState().chats; + if (chats && chats.length > 0 && currentChatIndex !== -1 && !config) { + const updatedChats: ChatInterface[] = JSON.parse(JSON.stringify(chats)); updatedChats[currentChatIndex].config = { ...defaultChatConfig }; setChats(updatedChats); }