probe whenever the active source changes

Track the active source id and probe when it changes, instead of a remembered probed id.
The behaviour is the same for switching sources, but the intent is now explicit: switch
source, probe it.
This commit is contained in:
austinried
2026-10-04 00:29:59 +00:00
parent 9c97f64381
commit af38f34ecd
@@ -31,7 +31,7 @@ class SourceRepository(
@Volatile @Volatile
private var active: SubsonicMusicSource? = null private var active: SubsonicMusicSource? = null
private var probedTokenAuthId: Long? = null private var activeSourceId: Long? = null
init { init {
scope.launch { scope.launch {
@@ -42,11 +42,10 @@ class SourceRepository(
) { config, maxBitrate, streamFormat -> Triple(config, maxBitrate, streamFormat) } ) { config, maxBitrate, streamFormat -> Triple(config, maxBitrate, streamFormat) }
.collect { (config, maxBitrate, streamFormat) -> .collect { (config, maxBitrate, streamFormat) ->
active = config?.toMusicSource(maxBitrate, streamFormat) active = config?.toMusicSource(maxBitrate, streamFormat)
config val sourceChanged = config?.id != activeSourceId
?.takeIf { it.useTokenAuth && it.id != probedTokenAuthId } activeSourceId = config?.id
?.let { source -> if (sourceChanged && config != null && config.useTokenAuth) {
probedTokenAuthId = source.id scope.launch { runCatching { config.toClient().check("ping") } }
scope.launch { runCatching { source.toClient().check("ping") } }
} }
} }
} }