Files
minstrel/web/src/lib/playlists/playlistTrackToRef.ts
T
bvandeusenandClaude Opus 5.5 10d50dccbd docs: web comments say what the app does, not how it came to be (#6277)
Rewrites the web app's comments to rule 32. Task, milestone, rule and
spec ids are gone; regression stories are restated as the trap they
guard (public auth routes, the menu's stopPropagation, universal loads
under adapter-static, metric deltas with their margin). Flutter and
Tauri mentions now name the Android app or a native shell, operator
quotes and dates are dropped, and one library's counts no longer
appear outside test fixtures. Verified with a TypeScript-scanner token
comparison (template literals and regex literals re-scanned): only
comment text changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 12:42:12 -04:00

29 lines
1.1 KiB
TypeScript

// Converts a PlaylistTrack row into the minimal TrackRef shape used
// by play queues + track menus. Centralizes the mapping so server
// additions (new TrackRef fields) only update one site.
//
// Returns null when the row cannot be played, for either of the two
// reasons a playlist entry can outlive its track:
// - track_id is null — the track was removed from the library and only
// the playlist's text snapshot remains.
// - unavailable — the track is still there, with its history intact,
// but its file is missing from disk.
// Callers filter nulls, which is what makes a missing file "get skipped"
// everywhere a queue is built rather than at each call site.
import type { PlaylistTrack, TrackRef } from '#lib/api/types.js';
export function playlistTrackToRef(row: PlaylistTrack): TrackRef | null {
if (!row.track_id || row.unavailable) return null;
return {
id: row.track_id,
title: row.title,
album_id: row.album_id ?? '',
album_title: row.album_title,
artist_id: row.artist_id ?? '',
artist_name: row.artist_name,
duration_sec: row.duration_sec,
stream_url: row.stream_url ?? ''
};
}