From af38f34ecd5dd7665ef1017c23a48d6af29bc13a Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Sat, 26 Sep 2026 02:02:35 +0000 Subject: [PATCH] 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. --- .../com/subtracks/data/repo/SourceRepository.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/subtracks/data/repo/SourceRepository.kt b/app/src/main/kotlin/com/subtracks/data/repo/SourceRepository.kt index 007a2317..1a0532db 100644 --- a/app/src/main/kotlin/com/subtracks/data/repo/SourceRepository.kt +++ b/app/src/main/kotlin/com/subtracks/data/repo/SourceRepository.kt @@ -31,7 +31,7 @@ class SourceRepository( @Volatile private var active: SubsonicMusicSource? = null - private var probedTokenAuthId: Long? = null + private var activeSourceId: Long? = null init { scope.launch { @@ -42,12 +42,11 @@ class SourceRepository( ) { config, maxBitrate, streamFormat -> Triple(config, maxBitrate, streamFormat) } .collect { (config, maxBitrate, streamFormat) -> active = config?.toMusicSource(maxBitrate, streamFormat) - config - ?.takeIf { it.useTokenAuth && it.id != probedTokenAuthId } - ?.let { source -> - probedTokenAuthId = source.id - scope.launch { runCatching { source.toClient().check("ping") } } - } + val sourceChanged = config?.id != activeSourceId + activeSourceId = config?.id + if (sourceChanged && config != null && config.useTokenAuth) { + scope.launch { runCatching { config.toClient().check("ping") } } + } } } }