summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-09-23 15:18:45 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-09-23 15:19:03 +0200
commite9c88ae4f42ad520814b139474a876706da22037 (patch)
treed0df0c81b54a02d8479087d043c132dba40ee05c
parentsend messages to users from the home page (SYWEB-19) (diff)
downloadsynapse-e9c88ae4f42ad520814b139474a876706da22037.tar.xz
Partial fix of SYWEB-28: If members do not have last_active_ago, compare their presence state to order them
-rw-r--r--webclient/app-filter.js18
1 files changed, 17 insertions, 1 deletions
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; };