Skip to content

Commit

Permalink
Merge pull request #6758 from alexbrazier/feature/real-name-sort
Browse files Browse the repository at this point in the history
[FIX] Sort by real name if use real name setting is enabled
  • Loading branch information
rodrigok authored Apr 24, 2017
2 parents f732073 + 84acd1f commit 324f86b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/rocketchat-ui-flextab/client/tabs/membersList.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ Template.membersList.helpers({
};
});

users = _.sortBy(users, u => u.user.username);
if (RocketChat.settings.get('UI_Use_Real_Name')) {
users = _.sortBy(users, u => u.user.name);
} else {
users = _.sortBy(users, u => u.user.username);
}
// show online users first.
// sortBy is stable, so we can do this
users = _.sortBy(users, u => u.status == null);
Expand Down
8 changes: 7 additions & 1 deletion packages/rocketchat-ui-sidenav/client/directMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Template.directMessages.helpers({

rooms() {
const query = { t: { $in: ['d']}, f: { $ne: true }, open: true };
const sort = { 't': 1 };

if (Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.unreadRoomsMode) {
query.$or = [
Expand All @@ -15,6 +16,11 @@ Template.directMessages.helpers({
];
}

return ChatSubscription.find(query, { sort: { 't': 1, 'name': 1 }});
if (RocketChat.settings.get('UI_Use_Real_Name')) {
sort.fname = 1;
}
sort.name = 1;

return ChatSubscription.find(query, { sort });
}
});

0 comments on commit 324f86b

Please sign in to comment.