Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ class HealthNotifier(
}
.collect { health ->
TSLog.d(TAG, "Health updated: ${health?.Warnings?.keys?.sorted()}")
health?.Warnings?.values?.filterNotNull()?.toTypedArray()?.let(::notifyHealthUpdated)
// A healthy backend sends Warnings = null; treat it as empty so that
// previously shown warnings are dropped.
notifyHealthUpdated(
health?.Warnings?.values?.filterNotNull()?.toTypedArray() ?: emptyArray()
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ class HealthNotifierTest {
assertTrue(notifier.currentWarnings.value.isEmpty())
}

/**
* The backend reports a fully healthy state as Warnings = null (a nil Go map), not as an empty
* map. The warning must still be dropped.
*/
@Test
fun warningClearsWhenBackendSendsNullWarnings() = runTest {
val (healthFlow, _, notifier) = createRunningNotifier()

healthFlow.value = healthState(derpWarning())
settle()
assertEquals(1, notifier.currentWarnings.value.size)

healthFlow.value = Health.State(Warnings = null)
settle()
assertTrue(notifier.currentWarnings.value.isEmpty())
assertNull(notifier.currentIcon.value)
}

@Test
fun warningsDroppedWhenStateLeavesRunning() = runTest {
val (healthFlow, ipnFlow, notifier) = createRunningNotifier()
Expand Down