From 58d46825ce67b9c8950436da0d9588e8138c9329 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 16 Mar 2016 22:27:09 +0000 Subject: [PATCH] take null last_active_ago values into account correctly when ordering tab complete --- src/TabCompleteEntries.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/TabCompleteEntries.js b/src/TabCompleteEntries.js index 9aef7736a8..a23050063f 100644 --- a/src/TabCompleteEntries.js +++ b/src/TabCompleteEntries.js @@ -127,15 +127,9 @@ MemberEntry.fromMemberList = function(members) { return 0; // don't care } else { // both User objects exist - if (userA.lastActiveAgo < userB.lastActiveAgo) { - return -1; // a comes first - } - else if (userA.lastActiveAgo > userB.lastActiveAgo) { - return 1; // b comes first - } - else { - return 0; // same last active ago - } + var lastActiveAgoA = userA.lastActiveAgo || Number.MAX_SAFE_INTEGER; + var lastActiveAgoB = userB.lastActiveAgo || Number.MAX_SAFE_INTEGER; + return lastActiveAgoA - lastActiveAgoB; } }).map(function(m) { return new MemberEntry(m);