diff --git a/src/lib/stores/library.ts b/src/lib/stores/library.ts index 3edd3f41..3936bd7f 100644 --- a/src/lib/stores/library.ts +++ b/src/lib/stores/library.ts @@ -202,7 +202,7 @@ function createLibraryStore() { const repo = auth.getRepository(); const item = await repo.getItem(itemId); - console.log(`[LibraryStore] loadItem(${itemId}): ${item.name} (${item.type})`); + console.log(`[LibraryStore] loadItem(${itemId}): ${item.name} (${item.kind})`); console.log(`[LibraryStore] - Has people? ${item.people ? `YES (${item.people.length})` : 'NO'}`); if (item.people && item.people.length > 0) { item.people.forEach((p, i) => { diff --git a/src/lib/utils/mediaKind.ts b/src/lib/utils/mediaKind.ts new file mode 100644 index 00000000..b53d5452 --- /dev/null +++ b/src/lib/utils/mediaKind.ts @@ -0,0 +1,31 @@ +// Presentation helpers for the neutral MediaKind. +// +// MediaKind is the app's provider-neutral item classification (defined in Rust, +// generated into bindings). This module holds *display* concerns over it — +// human-readable labels — which are presentation, not domain, and so live in +// the frontend. + +import type { MediaKind } from "$lib/api/types"; + +const KIND_LABELS: Record = { + track: "Song", + album: "Album", + artist: "Artist", + playlist: "Playlist", + movie: "Movie", + series: "Series", + season: "Season", + episode: "Episode", + person: "Person", + channel: "Channel", + liveChannel: "Live TV", + channelItem: "Channel", + folder: "Folder", + other: "", +}; + +/** Human-readable label for a media kind (e.g. "Album"), or "" if unknown. */ +export function kindLabel(kind: MediaKind | null | undefined): string { + if (!kind) return ""; + return KIND_LABELS[kind] ?? ""; +} diff --git a/src/routes/library/[id]/+page.svelte b/src/routes/library/[id]/+page.svelte index b95f63d6..0f669526 100644 --- a/src/routes/library/[id]/+page.svelte +++ b/src/routes/library/[id]/+page.svelte @@ -4,6 +4,7 @@ import { page } from "$app/stores"; import { goto } from "$app/navigation"; import { navigateBack } from "$lib/utils/navigation"; + import { kindLabel } from "$lib/utils/mediaKind"; import { commands } from "$lib/api/bindings"; import type { MediaItem, Library } from "$lib/api/types"; import { library, libraryItems, isLibraryLoading, currentLibrary, libraries } from "$lib/stores/library"; @@ -402,8 +403,8 @@
- {#if item.type} - {item.type} + {#if kindLabel(item.kind)} + {kindLabel(item.kind)} {/if} {#if item.durationMs} {formatDuration(item.durationMs)}