Skip to content

Commit 80a1ea1

Browse files
committed
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
1 parent 3e1212e commit 80a1ea1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

frontend/src/v2/utils/romArtwork.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ export function resolveRomArtwork(rom: DetailedRom): RomArtworkEntry[] {
134134
isVideo,
135135
};
136136
})
137-
.filter((entry) => entry !== null);
137+
.filter((entry): entry is NonNullable<typeof entry> => entry !== null)
138+
// Images before videos; sort is stable so original order holds within each group.
139+
.sort((a, b) => Number(a.isVideo) - Number(b.isVideo));
138140

139141
for (const def of artworkDefs) {
140142
if (!def.url || seen.has(def.url)) continue;

0 commit comments

Comments
 (0)