summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-24 16:41:45 -0400
committerCorey Hulen <corey@hulen.com>2017-03-24 13:41:45 -0700
commita2f78d01bd4d105da374c46bd40c2a585bddd536 (patch)
tree21bda99b1c795eb432a7990a611a913e8bb5f500 /webapp
parent5bf6ae04dfedc2e504ea8af5c71b2e9a8287e2b5 (diff)
downloadchat-a2f78d01bd4d105da374c46bd40c2a585bddd536.tar.gz
chat-a2f78d01bd4d105da374c46bd40c2a585bddd536.tar.bz2
chat-a2f78d01bd4d105da374c46bd40c2a585bddd536.zip
Fix LHS group message sorting (#5812)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/utils/channel_utils.jsx21
1 files changed, 19 insertions, 2 deletions
diff --git a/webapp/utils/channel_utils.jsx b/webapp/utils/channel_utils.jsx
index 2bb30af5c..d916ca254 100644
--- a/webapp/utils/channel_utils.jsx
+++ b/webapp/utils/channel_utils.jsx
@@ -102,13 +102,30 @@ export function sortChannelsByDisplayName(a, b) {
return (typeToPrefixMap[a.type] || defaultPrefix).localeCompare((typeToPrefixMap[b.type] || defaultPrefix), locale);
}
- if (a.display_name !== b.display_name) {
- return a.display_name.localeCompare(b.display_name, locale, {numeric: true});
+ const aDisplayName = getChannelDisplayName(a);
+ const bDisplayName = getChannelDisplayName(b);
+
+ if (aDisplayName !== bDisplayName) {
+ return aDisplayName.localeCompare(bDisplayName, locale, {numeric: true});
}
return a.name.localeCompare(b.name, locale, {numeric: true});
}
+function getChannelDisplayName(channel) {
+ if (channel.type !== Constants.GM_CHANNEL) {
+ return channel.display_name;
+ }
+
+ const currentUser = UserStore.getCurrentUser();
+
+ if (currentUser) {
+ return channel.display_name.replace(currentUser.username + ', ', '');
+ }
+
+ return channel.display_name;
+}
+
export function showCreateOption(channelType, isAdmin, isSystemAdmin) {
if (global.window.mm_license.IsLicensed !== 'true') {
return true;