add new reducer to ensure conversations are renewed on model change

This commit is contained in:
Daniel Avila 2023-03-09 18:57:37 -05:00
parent 30936573ac
commit 0ba92c4c03
7 changed files with 53 additions and 24 deletions

View file

@ -29,6 +29,20 @@ const currentSlice = createSlice({
incrementPage: (state) => {
state.pageNumber = state.pageNumber + 1;
},
setNewConvo: (state) => {
state.error = false;
state.title = 'New Chat';
state.conversationId = null;
state.parentMessageId = null;
state.jailbreakConversationId = null;
state.conversationSignature = null;
state.clientId = null;
state.invocationId = null;
state.chatGptLabel = null;
state.promptPrefix = null;
state.convosLoading = false;
state.pageNumber = 1;
},
setConvos: (state, action) => {
const newConvos = action.payload.filter((convo) => {
return !state.convos.some((c) => c.conversationId === convo.conversationId);
@ -46,7 +60,7 @@ const currentSlice = createSlice({
}
});
export const { setConversation, setConvos, setError, incrementPage, removeConvo, removeAll } =
export const { setConversation, setConvos, setNewConvo, setError, incrementPage, removeConvo, removeAll } =
currentSlice.actions;
export default currentSlice.reducer;