Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
60c99a44
Commit
60c99a44
authored
Feb 20, 2024
by
Danny Liu
Browse files
remove user message and response from DOM as pair
parent
32c79713
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
82 deletions
+94
-82
src/lib/components/chat/Messages.svelte
src/lib/components/chat/Messages.svelte
+90
-78
src/lib/components/chat/Messages/UserMessage.svelte
src/lib/components/chat/Messages/UserMessage.svelte
+4
-4
No files found.
src/lib/components/chat/Messages.svelte
View file @
60c99a44
...
@@ -221,6 +221,15 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -313,6 +324,7 @@
{/if}
{/if}
</div>
</div>
</div>
</div>
{/if}
{/each}
{/each}
{#if bottomPadding}
{#if bottomPadding}
...
...
src/lib/components/chat/Messages/UserMessage.svelte
View file @
60c99a44
<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 @@
...
@@ -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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment