cli: Fix sorting of `rad sync status`

This commit is contained in:
cloudhead 2023-12-01 12:51:56 +01:00
parent fe396ed5f4
commit 0decad5586
No known key found for this signature in database
1 changed files with 7 additions and 8 deletions

View File

@ -578,7 +578,12 @@ fn sort_seeds_by(local: NodeId, seeds: &mut [Seed], aliases: &impl AliasStore, s
let b = aliases.alias(&b.nid);
a.cmp(&b)
}
SortBy::Status => a.sync.cmp(&b.sync),
SortBy::Status => match (&a.sync, &b.sync) {
(Some(_), None) => Ordering::Less,
(None, Some(_)) => Ordering::Greater,
(Some(a), Some(b)) => a.cmp(b).reverse(),
(None, None) => Ordering::Equal,
},
};
// Always show our local node first.
@ -588,13 +593,7 @@ fn sort_seeds_by(local: NodeId, seeds: &mut [Seed], aliases: &impl AliasStore, s
} else if b.nid == local {
Ordering::Greater
} else {
match (&a.sync, &b.sync) {
(Some(_), None) => Ordering::Less,
(None, Some(_)) => Ordering::Greater,
(Some(a), Some(b)) => a.cmp(b).reverse(),
(None, None) => Ordering::Equal,
}
.then(compare(a, b))
compare(a, b)
}
});
}