summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-07-13 17:47:57 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-07-17 15:22:57 -0400
commit098cbcdc21effeebe7e57fbd912a785e85cbfc5d (patch)
treefca1c712fe315ed49058de974b21efdaa0dd5b9c /web
parentabcb44089c421872de582584049ca4cc6b268f37 (diff)
downloadchat-098cbcdc21effeebe7e57fbd912a785e85cbfc5d.tar.gz
chat-098cbcdc21effeebe7e57fbd912a785e85cbfc5d.tar.bz2
chat-098cbcdc21effeebe7e57fbd912a785e85cbfc5d.zip
Unify all locations where we determine a user's display named based off of their nickname/username into a helper function
Diffstat (limited to 'web')
-rw-r--r--web/react/components/member_list_team.jsx4
-rw-r--r--web/react/components/sidebar.jsx4
-rw-r--r--web/react/utils/utils.jsx8
3 files changed, 11 insertions, 5 deletions
diff --git a/web/react/components/member_list_team.jsx b/web/react/components/member_list_team.jsx
index 8d69a36d3..6f1d83193 100644
--- a/web/react/components/member_list_team.jsx
+++ b/web/react/components/member_list_team.jsx
@@ -85,8 +85,8 @@ var MemberListTeamItem = React.createClass({
return (
<div className="row member-div">
<img className="post-profile-img pull-left" src={"/api/v1/users/" + user.id + "/image?time=" + timestamp} height="36" width="36" />
- <span className="member-name">{user.nickname.trim() ? user.nickname : user.username}</span>
- <span className="member-email">{user.nickname.trim() ? user.username : email}</span>
+ <span className="member-name">{utils.getDisplayName(user)}</span>
+ <span className="member-email">{email}</span>
<div className="dropdown member-drop">
<a href="#" className="dropdown-toggle theme" type="button" id="channel_header_dropdown" data-toggle="dropdown" aria-expanded="true">
<span>{currentRoles} </span>
diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx
index 742720048..65727c597 100644
--- a/web/react/components/sidebar.jsx
+++ b/web/react/components/sidebar.jsx
@@ -131,7 +131,7 @@ function getStateFromStores() {
var channel = ChannelStore.getByName(channelName);
if (channel != null) {
- channel.display_name = teammate.nickname.trim() != "" ? teammate.nickname : teammate.username;
+ channel.display_name = utils.getDisplayName(teammate);
channel.teammate_username = teammate.username;
channel.status = UserStore.getStatus(teammate.id);
@@ -150,7 +150,7 @@ function getStateFromStores() {
var tempChannel = {};
tempChannel.fake = true;
tempChannel.name = channelName;
- tempChannel.display_name = teammate.nickname.trim() != "" ? teammate.nickname : teammate.username;
+ tempChannel.display_name = utils.getDisplayName(teammate);
tempChannel.status = UserStore.getStatus(teammate.id);
tempChannel.last_post_at = 0;
readDirectChannels.push(tempChannel);
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 7186251e7..5a1a7ee73 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -796,7 +796,6 @@ module.exports.getHomeLink = function() {
return window.location.protocol + "//" + parts.join(".");
}
-
module.exports.changeColor =function(col, amt) {
var usePound = false;
@@ -824,5 +823,12 @@ module.exports.changeColor =function(col, amt) {
else if (g < 0) g = 0;
return (usePound?"#":"") + String("000000" + (g | (b << 8) | (r << 16)).toString(16)).slice(-6);
+};
+module.exports.getDisplayName = function(user) {
+ if (user.nickname && user.nickname.trim().length > 0) {
+ return user.nickname;
+ } else {
+ return user.username;
+ }
};