fix: prevent the title from being empty, optimization Logic

This commit is contained in:
AprilNEA
2023-03-31 03:16:54 +08:00
parent 2da7e875d7
commit cf41cb1874
2 changed files with 21 additions and 34 deletions

View File

@@ -188,14 +188,13 @@ interface ChatStore {
removeSession: (index: number) => void;
selectSession: (index: number) => void;
newSession: () => void;
editDialogTitle: (index: number, title: string) => void;
updateSessionTitle: (index: number, title: string) => void;
currentSession: () => ChatSession;
onNewMessage: (message: Message) => void;
onUserInput: (content: string) => Promise<void>;
summarizeSession: () => void;
updateStat: (message: Message) => void;
updateCurrentSession: (updater: (session: ChatSession) => void) => void;
updateTitle: (title: string) => void;
updateMessage: (
sessionIndex: number,
messageIndex: number,
@@ -270,7 +269,7 @@ export const useChatStore = create<ChatStore>()(
});
},
editDialogTitle(index: number, title: string) {
updateSessionTitle(index: number, title: string) {
set((state) => {
const sessions = state.sessions;
sessions[index].topic = title;
@@ -409,10 +408,6 @@ export const useChatStore = create<ChatStore>()(
set(() => ({ sessions }));
},
updateTitle(title: string) {
get().updateCurrentSession((session) => (session.topic = title));
},
summarizeSession() {
const session = get().currentSession();