From 28ebe02bd68c02875ae6e2940083d791eeaa5e37 Mon Sep 17 00:00:00 2001 From: YasinOnm08 Date: Fri, 11 Oct 2024 08:44:30 +0200 Subject: [PATCH] chat actions should be fixed --- app/backend/InputOutputHandler.tsx | 16 ++++++++-------- app/components/History.tsx | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/backend/InputOutputHandler.tsx b/app/backend/InputOutputHandler.tsx index 3bf20f0..bcdd034 100644 --- a/app/backend/InputOutputHandler.tsx +++ b/app/backend/InputOutputHandler.tsx @@ -317,20 +317,20 @@ const InputOutputBackend: React.FC = () => { } const handleResendClick = () => { - const temporary_message = messages[messages.length - 2]['content'] - const updatedMessages = messages.slice(0, -2) - setMessages(updatedMessages) + const msg = chatHistory.chats[chatHistory.selectedIndex].messages + const lastUserMessage = msg[msg.length-2].content + msg.splice(msg.length-2,2) endGetWorker() getNewToken() setInputDisabled(false) - handleSendClick(temporary_message, true) + handleSendClick(lastUserMessage, true) } const handleEditClick = () => { - const newestMessage = messages[messages.length - 2].content - setInputMessage(newestMessage) - const updatedMessages = messages.slice(0, messages.length - 2) - setMessages(updatedMessages) + const msg = chatHistory.chats[chatHistory.selectedIndex].messages + const lastUserMessage = msg[msg.length-2].content + setInputMessage(lastUserMessage) + msg.splice(msg.length-2,2) endGetWorker() getNewToken() setInputDisabled(false) diff --git a/app/components/History.tsx b/app/components/History.tsx index b0b23aa..ad8e9af 100644 --- a/app/components/History.tsx +++ b/app/components/History.tsx @@ -46,7 +46,7 @@ const History: React.FC = () => { copyChats.chats = [...chatHistory.chats] // Remove the chat at the specified index - copyChats.chats.splice(index,1) + copyChats.chats.splice(index,1) // Determine new selectedIndex let newSelectedIndex = currentIndex;