From de60c516923f4661c0820fec43724f45549383fd Mon Sep 17 00:00:00 2001 From: Alex Brazier Date: Fri, 21 Apr 2017 22:14:11 +0100 Subject: [PATCH 1/2] Sort direct messages by name if real name setting enabled --- packages/rocketchat-ui-sidenav/client/directMessages.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-ui-sidenav/client/directMessages.js b/packages/rocketchat-ui-sidenav/client/directMessages.js index ae73370b526f..68e09b80d82e 100644 --- a/packages/rocketchat-ui-sidenav/client/directMessages.js +++ b/packages/rocketchat-ui-sidenav/client/directMessages.js @@ -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 = [ @@ -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 }); } }); From 84acd1f30d95a795ec46a35fd52a5cea648c8975 Mon Sep 17 00:00:00 2001 From: Alex Brazier Date: Fri, 21 Apr 2017 22:26:20 +0100 Subject: [PATCH 2/2] Sort members list by name if real name setting enabled --- packages/rocketchat-ui-flextab/client/tabs/membersList.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-ui-flextab/client/tabs/membersList.js b/packages/rocketchat-ui-flextab/client/tabs/membersList.js index c9e35fcd0a92..f6a92be62667 100644 --- a/packages/rocketchat-ui-flextab/client/tabs/membersList.js +++ b/packages/rocketchat-ui-flextab/client/tabs/membersList.js @@ -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);