fix(jukebox): fall back to the file name when a track's embedded title is empty (#5701)

* fix(jukebox): fall back to the file name when a track's embedded title is empty

panelTracksFromRom used ?? for the title, so an empty tag stayed an empty
title, while the catalog path (panelTracksFromCatalog) already falls back
to the file name with ||.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* test(jukebox): type the empty-title fixture instead of casting it

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Marcello Pichini
2026-11-21 16:06:12 +01:00
committed by GitHub
parent 084a6404e2
commit f448a6bbad
2 changed files with 9 additions and 1 deletions

View File

@@ -89,6 +89,14 @@ describe("panelTracksFromRom", () => {
expect(track?.title).toBe("01 - Theme");
expect(track?.subtitle).toBe("");
});
it("falls back to the file name when the embedded title is empty", () => {
const [track] = panelTracksFromRom(
rom([romFile(1, "theme.mp3")]),
new Map<number, TrackMetaSchema>([[1, { title: "" }]]),
);
expect(track?.title).toBe("theme");
});
});
describe("panelTracksFromCatalog", () => {

View File

@@ -86,7 +86,7 @@ export function panelTracksFromRom(
id: file.id,
romId: rom.id,
fileName: file.file_name,
title: meta?.title ?? stripExtension(file.file_name),
title: meta?.title || stripExtension(file.file_name),
subtitle: joinParts([meta?.artist, meta?.album]),
url: romFileUrl(file.id, file.file_name),
durationSeconds: meta?.duration_seconds ?? undefined,