combine save & submit and submit button

fixes #15
This commit is contained in:
Jing Hua 2023-03-05 23:08:46 +08:00
parent 4fa5c14734
commit 7a7db911c5
2 changed files with 5 additions and 14 deletions

View file

@ -65,17 +65,7 @@ const ChatContent = () => {
</div>
)}
<div className='text-center mt-6 flex justify-center gap-2'>
<button
className='btn relative btn-primary mt-2'
onClick={() => {
handleSubmit();
}}
>
Submit
</button>
</div>
<div className='w-full h-10'></div>
<div className='w-full h-36'></div>
</div>
</ScrollToBottom>
</div>

View file

@ -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) {
if (_content !== '') {
updatedMessages.push({ role: inputRole, content: _content });
}
_setContent('');
resetTextAreaHeight();
} else {