refactor(web): every cover thumbnail goes through Cover, so a failed load falls back (DRY W2)

Seven places drew their own cover image. The Missing, Suspect sources,
Hidden and Reports rows showed a Music2 icon only when the track had no
album; a cover that failed to load (not fetched yet, or gone) showed a
broken image. The queue row, play bar and Now Playing each set the
placeholder in their own onerror, and the playlist card's images had no
fallback at all.

Cover gains fallback="track" (the Music2 icon a track row uses), and all
seven go through it, so each one handles a missing src and a failed load
the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 03:09:15 -05:00
co-authored by Claude Opus 5.5
parent cceeaeb5c8
commit dae46ea980
11 changed files with 80 additions and 100 deletions
+5 -16
View File
@@ -1,7 +1,8 @@
<script lang="ts">
import Cover from '#lib/components/Cover.svelte';
import { plural } from '#lib/utils/plural.js';
import { pageTitle } from '#lib/branding.js';
import { Copy, Download, FolderX, Music2, Trash2 } from 'lucide-svelte';
import { Copy, Download, FolderX, Trash2 } from 'lucide-svelte';
import Modal from '#lib/components/Modal.svelte';
import { createMissingFilesQuery, forgetMissingTracks, MISSING_FILES_CSV_URL } from '#lib/api/admin.js';
import { errMessage } from '#lib/api/errors.js';
@@ -172,21 +173,9 @@
<ul class="divide-y divide-border">
{#each group.tracks as t (t.track_id)}
<li class="flex items-center gap-3 px-4 py-2" data-testid="missing-track-row">
<div
class="flex h-10 w-10 shrink-0 items-center justify-center rounded bg-surface-hover"
aria-hidden="true"
>
{#if t.album_id}
<img
src={coverUrl(t.album_id)}
alt=""
class="h-full w-full rounded object-cover"
loading="lazy"
/>
{:else}
<Music2 size={18} strokeWidth={1} class="text-text-muted" />
{/if}
</div>
<div class="h-10 w-10 shrink-0 overflow-hidden rounded" aria-hidden="true">
<Cover src={t.album_id ? coverUrl(t.album_id) : undefined} fallback="track" />
</div>
<div class="min-w-0 flex-1">
<div class="truncate text-sm text-text-primary">{t.title}</div>
@@ -1,7 +1,8 @@
<script lang="ts">
import Cover from '#lib/components/Cover.svelte';
import { plural } from '#lib/utils/plural.js';
import { pageTitle } from '#lib/branding.js';
import { Music2, CheckCircle2, Trash2, Play, Copy, ChevronRight, FileX } from 'lucide-svelte';
import { CheckCircle2, Trash2, Play, Copy, ChevronRight, FileX } from 'lucide-svelte';
import { useQueryClient } from '@tanstack/svelte-query';
import RowActionsMenu, { type RowAction } from '#lib/components/RowActionsMenu.svelte';
import TabStrip from '#lib/components/TabStrip.svelte';
@@ -208,13 +209,9 @@
{@const a = actionsFor(r)}
{@const open = !!expanded[r.track_id]}
<li class="flex items-start gap-4 p-3" data-testid="report-row">
<div class="flex h-12 w-12 shrink-0 items-center justify-center rounded-md bg-surface-hover" aria-hidden="true">
{#if r.album_id}
<img src={coverUrl(r.album_id)} alt="" class="h-full w-full rounded-md object-cover" loading="lazy" />
{:else}
<Music2 size={20} strokeWidth={1} class="text-text-muted" />
{/if}
</div>
<div class="h-12 w-12 shrink-0 overflow-hidden rounded-md" aria-hidden="true">
<Cover src={r.album_id ? coverUrl(r.album_id) : undefined} fallback="track" />
</div>
<div class="min-w-0 flex-1 space-y-1">
<div class="truncate text-sm font-medium text-text-primary">{r.title}</div>
<div class="truncate text-xs text-text-secondary">
@@ -1,7 +1,8 @@
<script lang="ts">
import Cover from '#lib/components/Cover.svelte';
import { plural } from '#lib/utils/plural.js';
import { pageTitle } from '#lib/branding.js';
import { FileCheck, Music2 } from 'lucide-svelte';
import { FileCheck } from 'lucide-svelte';
import { createSuspectSourcesQuery, removeSuspectFile, setSuspectVerdict } from '#lib/api/admin.js';
import { errMessage } from '#lib/api/errors.js';
import { pushToast } from '#lib/stores/toast.svelte.js';
@@ -158,21 +159,9 @@
<ul class="divide-y divide-border">
{#each group.tracks as t (t.track_id)}
<li class="flex items-center gap-3 px-4 py-2" data-testid="suspect-track-row">
<div
class="flex h-10 w-10 shrink-0 items-center justify-center rounded bg-surface-hover"
aria-hidden="true"
>
{#if t.album_id}
<img
src={coverUrl(t.album_id)}
alt=""
class="h-full w-full rounded object-cover"
loading="lazy"
/>
{:else}
<Music2 size={18} strokeWidth={1} class="text-text-muted" />
{/if}
</div>
<div class="h-10 w-10 shrink-0 overflow-hidden rounded" aria-hidden="true">
<Cover src={t.album_id ? coverUrl(t.album_id) : undefined} fallback="track" />
</div>
<div class="min-w-0 flex-1 space-y-0.5">
<div class="truncate text-sm text-text-primary">{t.title}</div>