mirror of
https://github.com/open-webui/open-webui
synced 2024-11-06 08:56:39 +00:00
remove user message and response from DOM as pair
This commit is contained in:
parent
32c7971300
commit
60c99a44f8
@ -221,6 +221,15 @@
|
|||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deleteMessage = async (messageId) => {
|
||||||
|
history.messages[messageId].deleted = true;
|
||||||
|
history.messages[history.messages[messageId].childrenIds[0]].deleted = true;
|
||||||
|
updateChatById(localStorage.token, chatId, {
|
||||||
|
messages: messages,
|
||||||
|
history: history
|
||||||
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if messages.length == 0}
|
{#if messages.length == 0}
|
||||||
@ -229,6 +238,7 @@
|
|||||||
<div class=" pb-10">
|
<div class=" pb-10">
|
||||||
{#key chatId}
|
{#key chatId}
|
||||||
{#each messages as message, messageIdx}
|
{#each messages as message, messageIdx}
|
||||||
|
{#if !message.deleted}
|
||||||
<div class=" w-full">
|
<div class=" w-full">
|
||||||
<div
|
<div
|
||||||
class="flex flex-col justify-between px-5 mb-3 {$settings?.fullScreenMode ?? null
|
class="flex flex-col justify-between px-5 mb-3 {$settings?.fullScreenMode ?? null
|
||||||
@ -237,6 +247,7 @@
|
|||||||
>
|
>
|
||||||
{#if message.role === 'user'}
|
{#if message.role === 'user'}
|
||||||
<UserMessage
|
<UserMessage
|
||||||
|
on:delete={() => deleteMessage(message.id)}
|
||||||
user={$user}
|
user={$user}
|
||||||
{message}
|
{message}
|
||||||
isFirstMessage={messageIdx === 0}
|
isFirstMessage={messageIdx === 0}
|
||||||
@ -313,6 +324,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
{#if bottomPadding}
|
{#if bottomPadding}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { tick } from 'svelte';
|
import { tick, createEventDispatcher } from 'svelte';
|
||||||
import Name from './Name.svelte';
|
import Name from './Name.svelte';
|
||||||
import ProfileImage from './ProfileImage.svelte';
|
import ProfileImage from './ProfileImage.svelte';
|
||||||
import { modelfiles, settings } from '$lib/stores';
|
import { modelfiles, settings } from '$lib/stores';
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
export let user;
|
export let user;
|
||||||
export let message;
|
export let message;
|
||||||
export let siblings;
|
export let siblings;
|
||||||
@ -286,9 +288,7 @@
|
|||||||
{#if !isFirstMessage}
|
{#if !isFirstMessage}
|
||||||
<button
|
<button
|
||||||
class="invisible group-hover:visible p-1 rounded dark:hover:text-white transition"
|
class="invisible group-hover:visible p-1 rounded dark:hover:text-white transition"
|
||||||
on:click={() => {
|
on:click={() => dispatch('delete', { messageId: message.id })}
|
||||||
// TODO delete message
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
Loading…
Reference in New Issue
Block a user