mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-23 01:06:48 +08:00
fix: fix new chat title subscription
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user