From 1803c7adebbb1c6b6bad3f873cfa1d08d5e0cd54 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 3 Sep 2024 15:24:58 +0200 Subject: [PATCH] refac --- src/lib/components/chat/Chat.svelte | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 69992ec09..6a39534d4 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1020,21 +1020,6 @@ scrollToBottom(); } } - - if ($chatId == _chatId) { - if ($settings.saveChatHistory ?? true) { - chat = await updateChatById(localStorage.token, _chatId, { - messages: messages, - history: history, - models: selectedModels, - params: params, - files: chatFiles - }); - - currentChatPage.set(1); - await chats.set(await getChatList(localStorage.token, $currentChatPage)); - } - } } else { if (res !== null) { const error = await res.json(); @@ -1066,6 +1051,7 @@ messages = messages; } + await saveChatHandler(_chatId); stopResponseFlag = false; await tick(); @@ -1335,18 +1321,7 @@ await handleOpenAIError(error, null, model, responseMessage); } - if ($chatId == _chatId) { - chat = await updateChatById(localStorage.token, _chatId, { - models: selectedModels, - messages: messages, - history: history, - params: params, - files: chatFiles - }); - - currentChatPage.set(1); - await chats.set(await getChatList(localStorage.token, $currentChatPage)); - } + await saveChatHandler(_chatId); messages = messages;