feat: deletion of messages

This commit is contained in:
Alexander Daichendt 2025-02-12 13:18:15 +01:00
parent 97f0483f9a
commit 4d87f86ff7
9 changed files with 111 additions and 24 deletions

View file

@ -2,6 +2,17 @@ import { ChatAction, ChatState } from "../contexts/ChatContext";
export function chatReducer(state: ChatState, action: ChatAction): ChatState {
switch (action.type) {
case "DELETE_MESSAGE":
return {
...state,
messages: state.messages.filter((message) => {
// only potentially delete chat messages, dont touch system messages
if ("type" in message && message.type === "CHAT_MESSAGE") {
return message.payload.id !== action.payload;
}
return true;
}),
};
case "ADD_MESSAGE":
return {
...state,