Skip to content

Commit e3549ba

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 e3549ba

1 file changed

Lines changed: 9 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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +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
45-
return WarnableCode.compareTo(other.WarnableCode)
44+
// If severities are equal, connectivity impacting issues first
45+
val connectivityComparison = (other.ImpactsConnectivity ?: false).compareTo(ImpactsConnectivity ?: false)
46+
if (connectivityComparison !=0){
47+
return connectivityComparison
48+
}
49+
50+
// Otherwise, alphabetical by title
51+
return Title.compareTo(other.Title)
4652
}
4753
}
4854

0 commit comments

Comments
 (0)