Skip to content

Commit 158145a

Browse files
committed
android: fix health warnings sort order
This changes the comparator to sort by severity first (descending), ImpactsConnectivity as a secondary sort, and title as a final tiebreaker. This fixes the issue where the comparator was sorting ascending, and matches the new WinUI sorting behavior. Fixes tailscale/corp#41733 Signed-off-by: kari-ts <kari@tailscale.com>
1 parent ea5bd4c commit 158145a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

  • android/src/main/java/com/tailscale/ipn/ui/model

android/src/main/java/com/tailscale/ipn/ui/model/Health.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ class Health {
3636

3737
override fun compareTo(other: UnhealthyState): Int {
3838
// Compare by severity first
39-
val severityComparison = Severity.compareTo(other.Severity)
39+
val severityComparison = other.Severity.compareTo(other.Severity)
4040
if (severityComparison != 0) {
4141
return severityComparison
4242
}
4343

44-
// If severities are equal, compare by warnableCode
44+
// If severities are equal, connectivity impacting issues first
45+
val connectivityComparison =
46+
(other.ImpactsConnectivity ?: false).compareTo(ImpactsConnectivity ?: false)
47+
if (connectivityComparison != 0) {
48+
return connectivityComparison
49+
}
50+
51+
// Otherwise, alphabetical by WarnableCode
4552
return WarnableCode.compareTo(other.WarnableCode)
4653
}
4754
}

0 commit comments

Comments
 (0)