diff --git a/android/app/src/main/java/tv/orbit/classic/SampleChannelScreens.kt b/android/app/src/main/java/tv/orbit/classic/SampleChannelScreens.kt index 09e01bab..66cd1c78 100644 --- a/android/app/src/main/java/tv/orbit/classic/SampleChannelScreens.kt +++ b/android/app/src/main/java/tv/orbit/classic/SampleChannelScreens.kt @@ -172,7 +172,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC catch (_: Exception) { problem = if (channel is ScheduledChannel) "This programme isn't available right now. Orbit moves on at ${clock(current.endMs)}." else "This scheduled programme could not be opened. Return to the guide and try again." } } // Suppress the preceding plan immediately at a boundary while the effect schedules its replacement. - val plan = loadedNow?.plan ?: prepared?.takeIf { (it.item.id == current.media.item.id || preparedFor == current.media.item.id) && preparedSlot == current.startMs && problem == null } + val plan = loadedNow?.plan ?: shownPlan(prepared, preparedFor, preparedSlot, current, problem) // The ident playing out, held on its last frame until the next programme's first picture is on screen. var heldIdent by remember(channel) { mutableStateOf(null) } // The block's ident chosen at the changeover, kept with the held ident so its length and overlay stay the same throughout. @@ -294,3 +294,11 @@ internal fun ClassicTuningNumber(number: Int, modifier: Modifier = Modifier) { style = androidx.compose.ui.text.TextStyle(shadow = androidx.compose.ui.graphics.Shadow( Color.Black, androidx.compose.ui.geometry.Offset(2f, 2f), 2f))) } + + +/** + * The prepared programme to show, if it's this slot's: the booked file itself, or a copy found again under a new number for + * it (re-filed after a rescan, 15 November 2026), and only when nothing went wrong. + */ +internal fun shownPlan(prepared: EmbyPlaybackPlan?, preparedFor: String?, preparedSlot: Long?, current: SampleBroadcast, problem: String?): EmbyPlaybackPlan? = + prepared?.takeIf { (it.item.id == current.media.item.id || preparedFor == current.media.item.id) && preparedSlot == current.startMs && problem == null } diff --git a/android/app/src/test/java/tv/orbit/classic/RefiledTest.kt b/android/app/src/test/java/tv/orbit/classic/RefiledTest.kt index a53ef523..a4d10b80 100644 --- a/android/app/src/test/java/tv/orbit/classic/RefiledTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/RefiledTest.kt @@ -146,3 +146,20 @@ class RecheckAfterRescanTest { } finally { dir.deleteRecursively() } } } + +/** 15 November 2026: the Drive-In's film, found again under a new number, stayed on tuning because the screen matched on the old one. */ +class RefiledPlaysTest { + private fun item(id: String) = SampleItem("Fixture Film", "Movie", 90, "", id, 90 * 60_000L) + private fun plan(id: String) = EmbyPlaybackPlan(item(id), "https://media.example.test/$id.mkv", "src$id", "fixture-play", emptyList(), 90 * 60_000L) + private val booked = SampleBroadcast(ScheduledMedia(item("old1"), "srcold1", 90 * 60_000L), 1_000L) + + @Test fun aCopyFoundAgainPlaysInItsBookedSlot() { + assertNotNull(shownPlan(plan("old1"), "old1", 1_000L, booked, null)) + // The re-filed copy, for the booked programme, in its slot: shown. + assertNotNull(shownPlan(plan("new1"), "old1", 1_000L, booked, null)) + // Prepared for another programme, another slot, or with a problem: not shown. + assertNull(shownPlan(plan("new1"), "other", 1_000L, booked, null)) + assertNull(shownPlan(plan("new1"), "old1", 2_000L, booked, null)) + assertNull(shownPlan(plan("new1"), "old1", 1_000L, booked, "This programme isn't available right now.")) + } +} diff --git a/docs/roadmap.md b/docs/roadmap.md index 6076ff6a..9ef0985b 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -483,4 +483,4 @@ A top-up scan gave some booked films and episodes new numbers in Emby. Three fix - RC3-8: the first renumbered programme on a channel rechecks the channel's whole schedule in one go and re-files the rest. - RC3-8: tuning ahead stops asking for a programme the server says is gone. - RC3-11: a re-filed film plays where the schedule keeps its old number (the Drive-In, Catch Up); before, it was found and - ready but the screen waited on tuning. To do: a test that holds this (the match is inside the screen's Compose code). + ready but the screen waited on tuning. Held by RefiledPlaysTest (shownPlan).