diff options
author | Jonathan <jonfritz@gmail.com> | 2017-07-24 08:22:19 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-07-24 08:22:19 -0400 |
commit | 87746227bfbc738bf79bda35cb8c06859f186c18 (patch) | |
tree | e585a2e6379b25dd1478090e314a3f3224b8f7ea /webapp/utils | |
parent | b27d51d512bbb73fb322d5613dafa299843f05b9 (diff) | |
download | chat-87746227bfbc738bf79bda35cb8c06859f186c18.tar.gz chat-87746227bfbc738bf79bda35cb8c06859f186c18.tar.bz2 chat-87746227bfbc738bf79bda35cb8c06859f186c18.zip |
PLT-3470: Changed all instances of user list to show full name, username, and nickname (#6994)
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/utils.jsx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index 0bd8c7bff..da5436737 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -1003,10 +1003,16 @@ export function getDisplayName(user) { return user.username; } +/** + * Gets the display name of the user with the specified id, respecting the TeammateNameDisplay configuration setting + */ export function displayUsername(userId) { return displayUsernameForUser(UserStore.getProfile(userId)); } +/** + * Gets the display name of the specified user, respecting the TeammateNameDisplay configuration setting + */ export function displayUsernameForUser(user) { if (user) { const nameFormat = global.window.mm_config.TeammateNameDisplay; @@ -1023,6 +1029,35 @@ export function displayUsernameForUser(user) { return ''; } +/** + * Gets the entire name, including username, full name, and nickname, of the user with the specified id + */ +export function displayEntireName(userId) { + return displayEntireNameForUser(UserStore.getProfile(userId)); +} + +/** + * Gets the entire name, including username, full name, and nickname, of the specified user + */ +export function displayEntireNameForUser(user) { + if (!user) { + return ''; + } + + let displayName = user.username; + const fullName = getFullName(user); + + if (fullName && user.nickname) { + displayName += ` - ${fullName} (${user.nickname})`; + } else if (fullName) { + displayName += ` - ${fullName}`; + } else if (user.nickname) { + displayName += ` - ${user.nickname}`; + } + + return displayName; +} + export function imageURLForUser(userIdOrObject) { if (typeof userIdOrObject == 'string') { const profile = UserStore.getProfile(userIdOrObject); |