fix: reset submission when convo clears

This commit is contained in:
Daniel Avila 2023-03-11 22:35:39 -05:00
parent 23de688bf3
commit f1aabfa543
8 changed files with 13 additions and 3 deletions

View file

@ -35,7 +35,6 @@ export default function Conversation({
if (!stopStream) {
dispatch(setStopStream(true));
dispatch(setSubmission({}));
dispatch(setSubmitState(false));
}
dispatch(setEmptyMessage());

View file

@ -5,6 +5,7 @@ import manualSWR from '~/utils/fetchers';
import { useDispatch } from 'react-redux';
import { setNewConvo, removeConvo } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
import { setSubmission } from '~/store/submitSlice';
export default function DeleteButton({ conversationId, renaming, cancelHandler }) {
const dispatch = useDispatch();
@ -15,6 +16,7 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler }
dispatch(setMessages([]));
dispatch(removeConvo(conversationId));
dispatch(setNewConvo());
dispatch(setSubmission({}));
}
);

View file

@ -1,7 +1,7 @@
import React, { useState, useRef } from 'react';
import TextareaAutosize from 'react-textarea-autosize';
import { useSelector, useDispatch } from 'react-redux';
import { setModel, setCustomGpt } from '~/store/submitSlice';
import { setSubmission, setModel, setCustomGpt } from '~/store/submitSlice';
import { setNewConvo } from '~/store/convoSlice';
import manualSWR from '~/utils/fetchers';
import { Button } from '../ui/Button.tsx';
@ -39,6 +39,7 @@ export default function ModelDialog({ mutate, setModelSave, handleSaveState }) {
handleSaveState(chatGptLabel.toLowerCase());
// Set new conversation
dispatch(setNewConvo());
dispatch(setSubmission({}));
};
const saveHandler = (e) => {

View file

@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { setModel, setDisabled, setCustomGpt, setCustomModel } from '~/store/submitSlice';
import { setSubmission, setModel, setDisabled, setCustomGpt, setCustomModel } from '~/store/submitSlice';
import { setNewConvo } from '~/store/convoSlice';
import ModelDialog from './ModelDialog';
import MenuItems from './MenuItems';
@ -77,6 +77,7 @@ export default function ModelMenu() {
// Set new conversation
dispatch(setNewConvo());
dispatch(setSubmission({}));
};
const onOpenChange = (open) => {

View file

@ -13,6 +13,7 @@ export default function ClearConvos() {
const { trigger } = manualSWR(`/api/convos/clear`, 'post', () => {
dispatch(setMessages([]));
dispatch(setNewConvo());
dispatch(setSubmission({}));
mutate(`/api/convos`);
});

View file

@ -18,6 +18,7 @@ export default function MobileNav({ setNavVisible }) {
dispatch(setText(''));
dispatch(setMessages([]));
dispatch(setNewConvo());
dispatch(setSubmission({}));
}
const title = convos?.find(element => element?.conversationId == conversationId)?.title || 'New Chat';

View file

@ -2,6 +2,7 @@ import React from 'react';
import { useDispatch } from 'react-redux';
import { setNewConvo } from '~/store/convoSlice';
import { setMessages } from '~/store/messageSlice';
import { setSubmission } from '~/store/submitSlice';
import { setText } from '~/store/textSlice';
export default function NewChat() {
@ -11,6 +12,7 @@ export default function NewChat() {
dispatch(setText(''));
dispatch(setMessages([]));
dispatch(setNewConvo());
dispatch(setSubmission({}));
};
return (

View file

@ -20,6 +20,9 @@ const currentSlice = createSlice({
},
setSubmission: (state, action) => {
state.submission = action.payload;
if (Object.keys(action.payload).length === 0) {
state.isSubmitting = false;
}
},
setStopStream: (state, action) => {
state.stopStream = action.payload;