fix(v2): order artwork images before videos, narrow filter with type guard

Sort library media so image entries precede video entries (stable sort
keeps original order within each group), and use a type-predicate filter
so the result stays typed as RomArtworkEntry[].

Generated-By: PostHog Code
Task-Id: fad7faa2-a17e-4583-a816-1b9915ba138f
This commit is contained in:
Georges-Antoine Assi
2026-07-07 11:00:13 -04:00
parent 3e1212e38d
commit 80a1ea18f8

View File

@@ -134,7 +134,9 @@ export function resolveRomArtwork(rom: DetailedRom): RomArtworkEntry[] {
isVideo,
};
})
.filter((entry) => entry !== null);
.filter((entry): entry is NonNullable<typeof entry> => entry !== null)
// Images before videos; sort is stable so original order holds within each group.
.sort((a, b) => Number(a.isVideo) - Number(b.isVideo));
for (const def of artworkDefs) {
if (!def.url || seen.has(def.url)) continue;