mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 15:11:58 +01:00
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:
@@ -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") } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user