fix: fix new chat title subscription

This commit is contained in:
AprilNEA
2023-03-31 03:33:17 +08:00
parent cf41cb1874
commit e361ec0cee
2 changed files with 20 additions and 28 deletions

View File

@@ -188,13 +188,13 @@ interface ChatStore {
removeSession: (index: number) => void;
selectSession: (index: number) => void;
newSession: () => 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,
@@ -269,17 +269,6 @@ export const useChatStore = create<ChatStore>()(
});
},
updateSessionTitle(index: number, title: string) {
set((state) => {
const sessions = state.sessions;
sessions[index].topic = title;
return {
sessions,
};
});
},
newSession() {
set((state) => ({
currentSessionIndex: 0,
@@ -408,6 +397,10 @@ export const useChatStore = create<ChatStore>()(
set(() => ({ sessions }));
},
updateTitle(title: string) {
get().updateCurrentSession((session) => (session.topic = title));
},
summarizeSession() {
const session = get().currentSession();