From a165c8385843c4f87e3eeb5797527004765e5708 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 11 Oct 2026 16:12:59 +0400 Subject: [PATCH] refac --- .../Messages/Message/ProfilePreview.svelte | 41 ++++--- .../chat/Messages/UserMessage.svelte | 15 ++- .../layout/Sidebar/ChannelItem.svelte | 93 +++++++------- .../components/layout/Sidebar/ChatItem.svelte | 115 ++++++++++-------- 4 files changed, 145 insertions(+), 119 deletions(-) diff --git a/src/lib/components/channel/Messages/Message/ProfilePreview.svelte b/src/lib/components/channel/Messages/Message/ProfilePreview.svelte index 3f859c1164..2fe8ff3a58 100644 --- a/src/lib/components/channel/Messages/Message/ProfilePreview.svelte +++ b/src/lib/components/channel/Messages/Message/ProfilePreview.svelte @@ -12,18 +12,18 @@ - - - - + {#snippet child({ props })} + + {/snippet} + - - + + +{:else} + +{/if} diff --git a/src/lib/components/chat/Messages/UserMessage.svelte b/src/lib/components/chat/Messages/UserMessage.svelte index 9b4dd7cdee..58132f044f 100644 --- a/src/lib/components/chat/Messages/UserMessage.svelte +++ b/src/lib/components/chat/Messages/UserMessage.svelte @@ -15,6 +15,7 @@ import Name from './Name.svelte'; import ProfileImage from './ProfileImage.svelte'; + import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte'; import Tooltip from '$lib/components/common/Tooltip.svelte'; import FileItem from '$lib/components/common/FileItem.svelte'; import Markdown from './Markdown.svelte'; @@ -158,12 +159,14 @@ - + + + {/if}
+ {#if channel?.type === 'dm' && channel?.users} + {@const channelMembers = channel.users.filter((u) => u.id !== $user?.id)} +
+
+ {#each channelMembers.slice(0, 2) as u, index} +
+ + {u.name} + +
+ {/each} + + {#if channelMembers.length === 1} +
+ + {#if channelMembers[0]?.is_active} + + {/if} + + +
+ {/if} +
+
+ {/if}
-
- {#if channel?.type === 'dm'} - {#if channel?.users} - {@const channelMembers = channel.users.filter((u) => u.id !== $user?.id)} -
- {#each channelMembers.slice(0, 2) as u, index} - {u.name} - {/each} - - {#if channelMembers.length === 1} -
- - {#if channelMembers[0]?.is_active} - - {/if} - - -
- {/if} -
- {:else} - - {/if} - {:else} -
- {#if isPublicChannel(channel)} - - {:else} - - {/if} -
+ {#if channel?.type === 'dm'} + {#if !channel?.users} + {/if} -
+ {:else} +
+ {#if isPublicChannel(channel)} + + {:else} + + {/if} +
+ {/if}
{#if channel?.name} diff --git a/src/lib/components/layout/Sidebar/ChatItem.svelte b/src/lib/components/layout/Sidebar/ChatItem.svelte index 1a85ad44f5..0ad2f9afde 100644 --- a/src/lib/components/layout/Sidebar/ChatItem.svelte +++ b/src/lib/components/layout/Sidebar/ChatItem.svelte @@ -50,6 +50,7 @@ import DragGhost from '$lib/components/common/DragGhost.svelte'; import Spinner from '$lib/components/common/Spinner.svelte'; import ChatHoverPreview from './ChatHoverPreview.svelte'; + import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte'; import ChatIcon from './icons/Chat.svelte'; import MoreHorizontalIcon from './icons/MoreHorizontal.svelte'; import SparklesIcon from './icons/Sparkles.svelte'; @@ -107,6 +108,9 @@ let focusWithin = false; let menuOpen = false; let openPreview = false; + let openProfilePreview = false; + + $: if (openProfilePreview) openPreview = false; const closeHoverPreview = () => { if (openPreview) { @@ -514,21 +518,6 @@ {#snippet chatItemContent()} - {#if ownerUserId} - - { - if (!e.currentTarget.src.endsWith('/static/favicon.png')) { - e.currentTarget.src = `${WEBUI_BASE_URL}/static/favicon.png`; - } - }} - /> - - {/if} - {#if active}
@@ -645,44 +634,68 @@ }} />
- {:else if $mobile} -
- {@render chatItemContent()} - {:else} - - - {@render chatItemContent()} - + {/if} {#if !readonly}