domain: delete dead jellyfinFieldMapping; scope playbackUnits to session boundary (phase 4e)

jellyfinFieldMapping.ts (SORT_FIELD_MAP friendly->Jellyfin sort names) had
zero consumers — sort code passes raw Jellyfin field names directly — so it
and its test are deleted.

playbackUnits.ts can't be removed: its tick<->seconds helpers are still the
correct converters for the remote Jellyfin *session* boundary
(SessionInfo.playState.positionTicks, NowPlayingItem.runTimeTicks), which
legitimately arrives in ticks. Documented that narrowed role; formatTime/
calculateProgress remain neutral seconds-based presentation helpers.

Note (out of scope): sortBy still passes raw Jellyfin field names
("SortName", "CommunityRating") — a separate sort-taxonomy leak that would
need its own Rust SortKey, like the search-scope work.

Frontend 626 tests (jellyfinFieldMapping's 18 removed with it), check clean.
This commit is contained in:
2026-07-23 22:13:54 +02:00
parent 1968c06172
commit 3a18ad060b
3 changed files with 13 additions and 244 deletions
+13 -11
View File
@@ -1,29 +1,31 @@
/**
* Playback unit conversion utilities
* Playback unit utilities.
*
* Jellyfin uses "ticks" for time values where 10 million ticks = 1 second.
* This module provides type-safe conversion functions to eliminate magic numbers
* and prevent conversion bugs across the codebase.
* The app's own media model speaks milliseconds (see the domain migration in
* docs/specs/frontend-domain-model.md), so catalog code does NOT use the tick
* helpers here. Ticks survive only at the **remote Jellyfin session boundary** —
* `SessionInfo.playState.positionTicks` and `NowPlayingItem.runTimeTicks` arrive
* straight from a live Jellyfin session and are converted here for display.
* `formatTime`/`calculateProgress` are plain seconds-based presentation helpers.
*/
/**
* Number of Jellyfin ticks per second (10 million)
* Number of Jellyfin ticks per second (10 million).
*
* Only for the remote-session boundary (see module doc); catalog durations are
* milliseconds and never touch this.
*/
export const TICKS_PER_SECOND = 10_000_000;
/**
* Convert seconds to Jellyfin ticks
* @param seconds - Time in seconds (e.g., 90.5 for 1 minute 30.5 seconds)
* @returns Time in Jellyfin ticks
* Convert seconds to Jellyfin ticks. Remote-session boundary only.
*/
export function secondsToTicks(seconds: number): number {
return Math.floor(seconds * TICKS_PER_SECOND);
}
/**
* Convert Jellyfin ticks to seconds
* @param ticks - Time in Jellyfin ticks
* @returns Time in seconds
* Convert Jellyfin session ticks to seconds. Remote-session boundary only.
*/
export function ticksToSeconds(ticks: number | null | undefined): number {
return (ticks ?? 0) / TICKS_PER_SECOND;