From 7a7db911c5cbdbf907ed124b40d951da565dfeda Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sun, 5 Mar 2023 23:08:46 +0800 Subject: [PATCH] combine `save & submit` and `submit` button fixes #15 --- src/components/Chat/ChatContent/ChatContent.tsx | 12 +----------- .../Chat/ChatContent/Message/MessageContent.tsx | 7 ++++--- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/components/Chat/ChatContent/ChatContent.tsx b/src/components/Chat/ChatContent/ChatContent.tsx index a93f611..8e44537 100644 --- a/src/components/Chat/ChatContent/ChatContent.tsx +++ b/src/components/Chat/ChatContent/ChatContent.tsx @@ -65,17 +65,7 @@ const ChatContent = () => { )} -
- -
-
+
diff --git a/src/components/Chat/ChatContent/Message/MessageContent.tsx b/src/components/Chat/ChatContent/Message/MessageContent.tsx index 70f1e3f..2e3cece 100644 --- a/src/components/Chat/ChatContent/Message/MessageContent.tsx +++ b/src/components/Chat/ChatContent/Message/MessageContent.tsx @@ -326,7 +326,7 @@ const EditView = ({ }; const handleSave = () => { - if (_content === '') return; + if (sticky && _content === '') return; const updatedChats: ChatInterface[] = JSON.parse( JSON.stringify(useStore.getState().chats) ); @@ -344,13 +344,14 @@ const EditView = ({ const { handleSubmit } = useSubmit(); const handleSaveAndSubmit = () => { - if (_content == '') return; const updatedChats: ChatInterface[] = JSON.parse( JSON.stringify(useStore.getState().chats) ); const updatedMessages = updatedChats[currentChatIndex].messages; if (sticky) { - updatedMessages.push({ role: inputRole, content: _content }); + if (_content !== '') { + updatedMessages.push({ role: inputRole, content: _content }); + } _setContent(''); resetTextAreaHeight(); } else {