fix(epg): drop malformed programmes from the list-view day filter

Reject programmes whose stop is not after their start in
buildEpgListRows — same as the timeline's buildTimelineBlocks. Bad
provider data would otherwise render impossible time ranges and could
even be offered as catch-up playable. (Codex P2 on e6fd0d08)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Opus 4.8 committed 2026-07-02 01:12:45 +02:00
1 parent e6fd0d0825
commit c6dbedd035
2 files changed
+24

No files matched your search

@@ -120,6 +120,24 @@ describe('buildEpgListRows', () => {
);
});
it('drops malformed programmes whose stop is not after their start', () => {
// Same as the timeline's buildTimelineBlocks: zero/negative durations
// from bad provider data must not render (or become catch-up playable).
const zeroDuration = programAt(-60, 0, 'Zero');
const negativeDuration = {
...programAt(-60, 60, 'Negative'),
stop: new Date(NOW - 120 * 60_000).toISOString(),
};
const rows = buildEpgListRows(
[zeroDuration, negativeDuration, programAt(-30, 60, 'Now')],
TODAY,
NOW,
DEFAULT_OPTS
);
expect(rows.map((r) => r.program.title)).toEqual(['Now']);
});
it('deduplicates programmes sharing a time slot, keeping the richer one', () => {
const rows = buildEpgListRows(
[
@@ -77,6 +77,12 @@ export function buildEpgListRows(
if (!Number.isFinite(startMs) || !Number.isFinite(stopMs)) {
return false;
}
// Drop malformed programmes (stop not after start) — same as the
// timeline's buildTimelineBlocks; they would render impossible time
// ranges and could even be offered as catch-up playable.
if (stopMs <= startMs) {
return false;
}
return startMs < dayEndMs && stopMs > dayStartMs;
});