mirror of
https://github.com/open-webui/open-webui
synced 2024-11-06 08:56:39 +00:00
Refactor deleteMessage function and update deleteMessagePair usage
This commit is contained in:
parent
cd3cecd2f0
commit
941bcdc2e5
@ -221,14 +221,13 @@
|
||||
scrollToBottom();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
const deleteMessage = async (messageId) => {
|
||||
|
||||
const deleteMessagePair = async (messageId) => {
|
||||
history.messages[messageId].deleted = true;
|
||||
history.messages[history.messages[messageId].childrenIds[0]].deleted = true;
|
||||
updateChatById(localStorage.token, chatId, {
|
||||
messages: messages,
|
||||
history: history
|
||||
});
|
||||
|
||||
await updateChatById(localStorage.token, chatId, { history });
|
||||
await chats.set(await getChatList(localStorage.token));
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -247,7 +246,7 @@
|
||||
>
|
||||
{#if message.role === 'user'}
|
||||
<UserMessage
|
||||
on:delete={() => deleteMessage(message.id)}
|
||||
on:delete={() => deleteMessagePair(message.id)}
|
||||
user={$user}
|
||||
{message}
|
||||
isFirstMessage={messageIdx === 0}
|
||||
|
@ -45,6 +45,10 @@
|
||||
edit = false;
|
||||
editedContent = '';
|
||||
};
|
||||
|
||||
const deleteMessageHandler = async () => {
|
||||
dispatch('delete', message.id);
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class=" flex w-full">
|
||||
@ -288,7 +292,9 @@
|
||||
{#if !isFirstMessage}
|
||||
<button
|
||||
class="invisible group-hover:visible p-1 rounded dark:hover:text-white transition"
|
||||
on:click={() => dispatch('delete', { messageId: message.id })}
|
||||
on:click={() => {
|
||||
deleteMessageHandler();
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
Loading…
Reference in New Issue
Block a user