mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Unify all locations where we determine a user's display named based off of their nickname/username into a helper function
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user