Fix crash rendering tweets published before tweet.media existed

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014c1L8ghNBFjfiH64UMViP8
This commit is contained in:
Claude
2026-07-23 00:16:34 +00:00
parent d4ab690061
commit 78f59287dc
+3 -1
View File
@@ -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 <video controls> needs its clicks not to fall through to the card's own
// <a> navigation (play/pause/scrub would otherwise just open the article instead).