From 78f59287dc164b48a35ca414f5fa035e56c91218 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 23 Jul 2026 00:16:34 +0000 Subject: [PATCH] Fix crash rendering tweets published before tweet.media existed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit article.tweet?.media.slice(...) only guarded against a missing tweet object, not a missing media array — pre-existing published tweets in the DB predate that field and threw "Cannot read properties of undefined (reading 'slice')" on every category page containing one. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_014c1L8ghNBFjfiH64UMViP8 --- frontend/src/lib/components/TweetCard.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/TweetCard.svelte b/frontend/src/lib/components/TweetCard.svelte index 9d98156..8ad62da 100644 --- a/frontend/src/lib/components/TweetCard.svelte +++ b/frontend/src/lib/components/TweetCard.svelte @@ -6,7 +6,9 @@ let { article }: { article: MergedArticle } = $props(); const sourceLabel = $derived(article.sources[0]?.sourceName ?? 'Nitter'); - const media = $derived(article.tweet?.media.slice(0, 4) ?? []); + // article.tweet.media is undefined for tweets published before this field existed — + // older rows in the DB weren't backfilled, so this can't assume it's always an array. + const media = $derived(article.tweet?.media?.slice(0, 4) ?? []); // Native