From 959c0f0669c90c48679c8a31c4c3c4efd3c6b745 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 21 Jul 2015 11:05:24 -0700 Subject: [PATCH] Order room members by lastActiveAgo --- src/controllers/organisms/MemberList.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/controllers/organisms/MemberList.js b/src/controllers/organisms/MemberList.js index 29d4f20a..41829348 100644 --- a/src/controllers/organisms/MemberList.js +++ b/src/controllers/organisms/MemberList.js @@ -115,6 +115,18 @@ module.exports = { var cli = MatrixClientPeg.get(); var all_members = cli.getRoom(this.props.roomId).currentState.members; var all_user_ids = Object.keys(all_members); + + all_user_ids.sort(function(userIdA, userIdB) { + var userA = all_members[userIdA].user; + var userB = all_members[userIdB].user; + + var latA = userA ? userA.lastActiveAgo || Number.MAX_VALUE : Number.MAX_VALUE; + var latB = userB ? userB.lastActiveAgo || Number.MAX_VALUE : Number.MAX_VALUE; + + return latA - latB; + }); + + var to_display = {}; var count = 0; for (var i = 0; i < all_user_ids.length && (limit === undefined || count < limit); ++i) {