Order room members by lastActiveAgo

This commit is contained in:
David Baker 2015-07-21 11:05:24 -07:00
parent 8dc73cb6cc
commit 959c0f0669
1 changed files with 12 additions and 0 deletions

View File

@ -115,6 +115,18 @@ module.exports = {
var cli = MatrixClientPeg.get(); var cli = MatrixClientPeg.get();
var all_members = cli.getRoom(this.props.roomId).currentState.members; var all_members = cli.getRoom(this.props.roomId).currentState.members;
var all_user_ids = Object.keys(all_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 to_display = {};
var count = 0; var count = 0;
for (var i = 0; i < all_user_ids.length && (limit === undefined || count < limit); ++i) { for (var i = 0; i < all_user_ids.length && (limit === undefined || count < limit); ++i) {