A Jellypod podcast listed its episodes alphabetically. The store pinned SortBy=SortName onto every drill-down, which overrode the order the channel plugin returns — and since Jellypod prefixes played episodes with "[Played]", the name sort also clumped every heard episode at the top. Which order a container's children take is domain knowledge, so it moves to Rust: the caller names the container (GetItemsOptions.parentKind) and default_listing_sort answers with the sort. A channel folder is PremiereDate descending, every other container keeps SortName ascending, and a caller naming no container still gets no SortBy, so the paths that rely on the server's own order keep it. An explicit sort always wins. ChannelFolderItem with is_folder now maps to MediaKind::ChannelFolder instead of collapsing into Folder — while both were Folder there was nothing to key the rule on. The offline leg of the cache/server race applies the same order, so the cached list no longer flashes in name order before the server's arrives. TRACES: UR-007 | DR-257 | UT-229, UT-230, UT-231
33 lines
939 B
TypeScript
33 lines
939 B
TypeScript
// 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<MediaKind, string> = {
|
|
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",
|
|
channelFolder: "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] ?? "";
|
|
}
|