Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Show usernames after display names
Browse files Browse the repository at this point in the history
Signed-off-by: Šimon Brandner <[email protected]>
  • Loading branch information
SimonBrandner committed Apr 18, 2021
1 parent ac00c80 commit 1b801e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
12 changes: 12 additions & 0 deletions res/css/views/messages/_SenderProfile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_SenderProfile_nameFlair {
display: flex;
align-items: center;
gap: 5px;
}

.mx_SenderProfile_name {
font-weight: 600;
}

.mx_SenderProfile_username {
font-weight: 600;
font-family: monospace;
font-size: 1rem;
color: gray;
}
20 changes: 11 additions & 9 deletions src/components/views/messages/SenderProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class SenderProfile extends React.Component {
const colorClass = getUserNameColorClass(mxEvent.getSender());
const name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender();
const {msgtype} = mxEvent.getContent();
const username = mxEvent.getSender();

if (msgtype === 'm.emote') {
return <span />; // emote message must include the name so don't duplicate it
Expand All @@ -109,19 +110,20 @@ export default class SenderProfile extends React.Component {
}

const nameElem = name || '';

// Name + flair
const nameFlair = <span>
<span className={`mx_SenderProfile_name ${colorClass}`}>
{ nameElem }
</span>
{ flair }
</span>;
const usernameElem = `[${username || ""}]`;

return (
<div className="mx_SenderProfile" dir="auto" onClick={this.props.onClick}>
<div className="mx_SenderProfile_hover">
{ nameFlair }
<div className="mx_SenderProfile_nameFlair">
<span className={`mx_SenderProfile_name ${colorClass}`}>
{ nameElem }
</span>
<span className="mx_SenderProfile_username">
{ usernameElem }
</span>
{ flair }
</div>
</div>
</div>
);
Expand Down

0 comments on commit 1b801e8

Please sign in to comment.