diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index 64574530f..c9e516abb 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -222,6 +222,34 @@ scrollToBottom(); }, 100); }; + + // TODO: change delete behaviour + // const deleteMessageAndDescendants = async (messageId: string) => { + // if (history.messages[messageId]) { + // history.messages[messageId].deleted = true; + + // for (const childId of history.messages[messageId].childrenIds) { + // await deleteMessageAndDescendants(childId); + // } + // } + // }; + + // const triggerDeleteMessageRecursive = async (messageId: string) => { + // await deleteMessageAndDescendants(messageId); + // await updateChatById(localStorage.token, chatId, { history }); + // await chats.set(await getChatList(localStorage.token)); + // }; + + const messageDeleteHandler = async (messageId) => { + if (history.messages[messageId]) { + history.messages[messageId].deleted = true; + + for (const childId of history.messages[messageId].childrenIds) { + history.messages[childId].deleted = true; + } + } + await updateChatById(localStorage.token, chatId, { history }); + }; {#if messages.length == 0} @@ -230,99 +258,103 @@
{message.content}-