Jonathan Nobels 5 days ago committed by GitHub
commit f0f08e1594
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -45,26 +45,30 @@ class HealthNotifier(
"wantrunning-false") "wantrunning-false")
init { init {
// This roughly matches the iOS/macOS implementation in terms of debouncing, and ingoring
// health warnings in various states.
scope.launch { scope.launch {
healthStateFlow healthStateFlow
.distinctUntilChanged { old, new -> old?.Warnings?.count() == new?.Warnings?.count() } .distinctUntilChanged { old, new -> old?.Warnings?.count() == new?.Warnings?.count() }
.combine(ipnStateFlow, ::Pair) .combine(ipnStateFlow, ::Pair)
.debounce(5000) .debounce(3000)
.collect { pair -> .collect { pair ->
val health = pair.first val health = pair.first
val ipnState = pair.second // When the client is Stopped, requires Login or has no state, we should drop all
// When the client is Stopped, no warnings should get added, and any warnings added // existing warnings
// previously should be removed. when (val ipnState = pair.second) {
if (ipnState == Ipn.State.Stopped) { Ipn.State.NeedsLogin,
TSLog.d( Ipn.State.Stopped,
TAG, Ipn.State.NoState -> {
"Ignoring and dropping all pre-existing health messages in the Stopped state") TSLog.d(TAG, "Ignoring and dropping all health messages in state ${ipnState}")
dropAllWarnings() dropAllWarnings()
return@collect return@collect
} else { }
TSLog.d(TAG, "Health updated: ${health?.Warnings?.keys?.sorted()}") else -> {
health?.Warnings?.let { TSLog.d(TAG, "Health updated: ${health?.Warnings?.keys?.sorted()}")
notifyHealthUpdated(it.values.mapNotNull { it }.toTypedArray()) health?.Warnings?.let {
notifyHealthUpdated(it.values.mapNotNull { it }.toTypedArray())
}
} }
} }
} }

Loading…
Cancel
Save