diff options
Diffstat (limited to 'webapp/utils/channel_utils.jsx')
-rw-r--r-- | webapp/utils/channel_utils.jsx | 21 |
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; |