mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-18 06:53:41 +08:00
feat: Add button to remove messages and responses
This commit is contained in:
@@ -194,6 +194,7 @@ interface ChatStore {
|
||||
summarizeSession: () => void;
|
||||
updateStat: (message: Message) => void;
|
||||
updateCurrentSession: (updater: (session: ChatSession) => void) => void;
|
||||
removeMessage: (sessionIndex: number, messageIndex: number) => void;
|
||||
updateMessage: (
|
||||
sessionIndex: number,
|
||||
messageIndex: number,
|
||||
@@ -384,6 +385,15 @@ export const useChatStore = create<ChatStore>()(
|
||||
return recentMessages;
|
||||
},
|
||||
|
||||
removeMessage(sessionIndex: number, messageIndex: number) {
|
||||
const sessions = get().sessions;
|
||||
const session = sessions.at(sessionIndex);
|
||||
const messages = session?.messages;
|
||||
// remove user's message and bot's response
|
||||
messages?.splice(messageIndex, 2);
|
||||
set(() => ({ sessions }));
|
||||
},
|
||||
|
||||
updateMessage(
|
||||
sessionIndex: number,
|
||||
messageIndex: number,
|
||||
|
||||
Reference in New Issue
Block a user