admin user: Sort bot owners by name.

The original commit here was sorting bot owners by
id, which is of course meaningless to users:

    444ce74a8e

It was also returning 1/-1 in cases where the bot
owner on both sides of a comparison were missing,
which is a big no-no for sorting algorithms.
This commit is contained in:
Steve Howell 2020-04-15 13:35:14 +00:00 committed by Tim Abbott
parent 0b71b092b3
commit aa5ffcbd2e
1 changed files with 17 additions and 3 deletions

View File

@ -39,10 +39,24 @@ function sort_role(a, b) {
}
function sort_bot_owner(a, b) {
if (!a.bot_owner_id) { return 1; }
if (!b.bot_owner_id) { return -1; }
function owner_name(item) {
const owner = people.get_bot_owner_user(item);
return compare_a_b(a.bot_owner_id, b.bot_owner_id);
if (!owner) {
return '';
}
if (!owner.full_name) {
return '';
}
return owner.full_name.toLowerCase();
}
return compare_a_b(
owner_name(a),
owner_name(b)
);
}
function sort_last_active(a, b) {