Setting channels up no longer restarts the background round for each one (0.108.54)

Seen on the upstairs box: each channel set up changed extraChannels, which restarted the
hourly top-up round from the first channel, so 305 and 601 were re-planned dozens of
times while setting up. The round now waits until setting up is over, then a moment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-06 12:46:56 +00:00
co-authored by Claude Opus 5.5
parent 150893686f
commit 6b65a230ea
4 changed files with 11 additions and 5 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 213
versionName = "0.108.53-autoscan"
versionCode = 214
versionName = "0.108.54-setup-once"
}
buildFeatures { compose = true }
// Android logging and the like do nothing in unit tests, so whole flows (a channel read from a fake server) can run.
@@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
}
/** The sign-in headers for this kind of server. */
internal fun authHeaders(token: String?): Map<String, String> = when (kind) {
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.53\"") +
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.54\"") +
(token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap())
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.53\"" +
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.54\"" +
(token?.let { ", Token=\"$it\"" } ?: ""))
}
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
@@ -48,6 +48,7 @@ import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.Job
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.delay
@@ -373,6 +374,11 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
reminders = liveReminders(scheduleStore.loadReminders(active.accountId), System.currentTimeMillis()) } }
catch (cancelled: CancellationException) { throw cancelled }
catch (_: Exception) { /* The round below tries again. */ }
// Setting channels up adds each to extraChannels, which restarts this round from the first channel every time: with
// 30 channels that was hundreds of needless top-ups (seen on the upstairs box, 6 November 2026). Wait until setting up
// is over, and a moment more so a run of changes counts once.
androidx.compose.runtime.snapshotFlow { ChannelSetup.wanted.isEmpty() || ChannelSetup.finished }.first { it }
delay(3_000)
while (true) {
for (programming in SmartChannels) {
val loop = smartLoop(programming) ?: continue
@@ -39,7 +39,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
next.instanceFollowRedirects = false
next.connectTimeout = 10_000
next.readTimeout = 20_000
next.setRequestProperty("User-Agent", "OrbitTV/0.108.53")
next.setRequestProperty("User-Agent", "OrbitTV/0.108.54")
next.setRequestProperty("Accept-Encoding", "identity")
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {