From a1400eea7b1bd9b7e66c0a698bfb02dc82eadb48 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 6 Mar 2026 23:56:57 -0800 Subject: simplify imeta image rendering to plain string array Co-Authored-By: Claude Opus 4.6 --- src/components/ChatMessage.svelte | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'src/components') diff --git a/src/components/ChatMessage.svelte b/src/components/ChatMessage.svelte index 8f8db31a..aeaac210 100644 --- a/src/components/ChatMessage.svelte +++ b/src/components/ChatMessage.svelte @@ -3,21 +3,14 @@ let { content, tags = [] }: { content: string; tags?: any[] } = $props(); - // Extract media from imeta tags (NIP-92) - let imetaMedia = $derived( + // Extract image URLs from imeta tags (NIP-92) + let imageUrls: string[] = $derived( tags - .filter((t) => t[0] === "imeta") - .map((t) => ({ - url: t.find((v) => v.startsWith("url "))?.slice(4) || "", - mime: t.find((v) => v.startsWith("m "))?.slice(2) || "", - })) - .filter((m) => m.url), + .filter((t: string[]) => t[0] === "imeta" && t.some((v) => v.startsWith("m image/"))) + .map((t: string[]) => t.find((v) => v.startsWith("url "))?.slice(4)) + .filter((url): url is string => !!url), ); - $effect(() => { - console.log("[ChatMessage]", { content, tags: JSON.stringify(tags), imetaMedia: JSON.stringify(imetaMedia) }); - }); - let parts = $derived(parseContent({ content, tags })); const truncUrl = (url: string) => { @@ -37,17 +30,10 @@ }; -{#each imetaMedia as media} - {#if media.mime.startsWith("image/")} - - - - {:else if media.mime.startsWith("video/")} - - - {:else} - {truncUrl(media.url)} - {/if} +{#each imageUrls as url} + + + {/each} {#each parts as { type, value }} -- cgit v1.2.3