summaryrefslogtreecommitdiffstats
path: root/webapp/utils/channel_utils.jsx
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-05-03 11:48:44 -0400
committerCorey Hulen <corey@hulen.com>2017-05-03 08:48:44 -0700
commitdc6c836b354bfdbedd0ac9f827c1ab4ec82d9425 (patch)
tree1452da32546865eb5ec00df377cb5f5108ffb94a /webapp/utils/channel_utils.jsx
parent1c8fdb4cdd3469d49fcd5a051d1e92111e87162d (diff)
downloadchat-dc6c836b354bfdbedd0ac9f827c1ab4ec82d9425.tar.gz
chat-dc6c836b354bfdbedd0ac9f827c1ab4ec82d9425.tar.bz2
chat-dc6c836b354bfdbedd0ac9f827c1ab4ec82d9425.zip
Fix group message names in channel switcher (#6246)
Diffstat (limited to 'webapp/utils/channel_utils.jsx')
-rw-r--r--webapp/utils/channel_utils.jsx14
1 files changed, 12 insertions, 2 deletions
diff --git a/webapp/utils/channel_utils.jsx b/webapp/utils/channel_utils.jsx
index 2930e58b6..10d06fbe1 100644
--- a/webapp/utils/channel_utils.jsx
+++ b/webapp/utils/channel_utils.jsx
@@ -112,7 +112,9 @@ export function sortChannelsByDisplayName(a, b) {
return a.name.localeCompare(b.name, locale, {numeric: true});
}
-function getChannelDisplayName(channel) {
+const MAX_CHANNEL_NAME_LENGTH = 64;
+
+export function getChannelDisplayName(channel) {
if (channel.type !== Constants.GM_CHANNEL) {
return channel.display_name;
}
@@ -120,7 +122,15 @@ function getChannelDisplayName(channel) {
const currentUser = UserStore.getCurrentUser();
if (currentUser) {
- return channel.display_name.replace(currentUser.username + ', ', '');
+ let displayName = channel.display_name;
+ if (displayName.length >= MAX_CHANNEL_NAME_LENGTH) {
+ displayName += '...';
+ }
+ displayName = displayName.replace(currentUser.username + ', ', '').replace(currentUser.username, '').trim();
+ if (displayName[displayName.length - 1] === ',') {
+ return displayName.slice(0, -1);
+ }
+ return displayName;
}
return channel.display_name;