Skip to content

Commit 7cb4b17

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 7cb4b17

1 file changed

Lines changed: 10 additions & 3 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: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,20 @@ 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
45-
return WarnableCode.compareTo(other.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 title
52+
return Title.compareTo(other.Title)
4653
}
4754
}
4855

0 commit comments

Comments
 (0)