From e9c88ae4f42ad520814b139474a876706da22037 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Tue, 23 Sep 2014 15:18:45 +0200 Subject: Partial fix of SYWEB-28: If members do not have last_active_ago, compare their presence state to order them --- webclient/app-filter.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'webclient') diff --git a/webclient/app-filter.js b/webclient/app-filter.js index ee9374668b..0d059e1621 100644 --- a/webclient/app-filter.js +++ b/webclient/app-filter.js @@ -70,7 +70,23 @@ angular.module('matrixWebClient') }); filtered.sort(function (a, b) { - return ((a["last_active_ago"] || 10e10) > (b["last_active_ago"] || 10e10) ? 1 : -1); + // Sort members on their last_active_ago value + if (undefined !== a.last_active_ago || undefined !== b.last_active_ago) { + return ((a.last_active_ago || 10e10) > (b.last_active_ago || 10e10) ? 1 : -1); + } + else { + // If they do not have last_active_ago, sort them according to their presence state + // Online users go first amongs members who do not have last_active_ago + var presenceLevels = { + offline: 1, + unavailable: 2, + online: 4, + free_for_chat: 3 + }; + var aPresence = (a.presence in presenceLevels) ? presenceLevels[a.presence] : 0; + var bPresence = (b.presence in presenceLevels) ? presenceLevels[b.presence] : 0; + return bPresence - aPresence; + } }); return filtered; }; -- cgit 1.4.1