diff --git a/web/src/components/ChatInfoPanel.tsx b/web/src/components/ChatInfoPanel.tsx index f0c9be1..b9c6274 100644 --- a/web/src/components/ChatInfoPanel.tsx +++ b/web/src/components/ChatInfoPanel.tsx @@ -63,11 +63,14 @@ export function ChatInfoPanel({ chatId, open, onClose }: Props) { const isGroupLike = chat?.type === "group" || chat?.type === "channel"; const showMembersSection = Boolean(chat && isGroupLike && !chat.is_saved); const canManageMembers = Boolean(isGroupLike && (myRole === "owner" || myRole === "admin")); - const photoAttachments = useMemo(() => attachments.filter((item) => item.file_type.startsWith("image/")), [attachments]); - const videoAttachments = useMemo(() => attachments.filter((item) => item.file_type.startsWith("video/")), [attachments]); - const voiceAttachments = useMemo(() => attachments.filter((item) => item.message_type === "voice"), [attachments]); + const photoAttachments = useMemo(() => attachments.filter((item) => item.file_type.startsWith("image/")).sort((a, b) => b.id - a.id), [attachments]); + const videoAttachments = useMemo(() => attachments.filter((item) => item.file_type.startsWith("video/")).sort((a, b) => b.id - a.id), [attachments]); + const voiceAttachments = useMemo(() => attachments.filter((item) => item.message_type === "voice").sort((a, b) => b.id - a.id), [attachments]); const audioAttachments = useMemo( - () => attachments.filter((item) => item.message_type === "audio" || (item.file_type.startsWith("audio/") && item.message_type !== "voice")), + () => + attachments + .filter((item) => item.message_type === "audio" || (item.file_type.startsWith("audio/") && item.message_type !== "voice")) + .sort((a, b) => b.id - a.id), [attachments] ); const allAttachmentItems = useMemo(() => [...attachments].sort((a, b) => b.id - a.id), [attachments]); @@ -386,48 +389,48 @@ export function ChatInfoPanel({ chatId, open, onClose }: Props) {

Media & Files {attachments.length > 0 ? `(${attachments.length})` : ""}

-
+
{attachmentsLoading ?

Loading attachments...

: null} @@ -518,8 +521,9 @@ export function ChatInfoPanel({ chatId, open, onClose }: Props) { }} type="button" > -

{item.url}

-

{new Date(item.createdAt).toLocaleString()}

+

{shortLink(item.url)}

+

{item.url}

+

{new Date(item.createdAt).toLocaleString()}

))}
@@ -821,3 +825,12 @@ function extractLinkItems(messages: Message[]): Array<{ url: string; messageId: out.sort((a, b) => b.messageId - a.messageId); return out; } + +function shortLink(url: string): string { + try { + const parsed = new URL(url); + return `${parsed.hostname}${parsed.pathname === "/" ? "" : parsed.pathname}`; + } catch { + return url; + } +}