From b131637a11b7ff19d640d735809bbb0f5b7bdfa1 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 19 Jul 2017 11:00:26 +0100 Subject: [PATCH] Add mx_UserPill_me class to user pills that match credentials.userId --- src/components/views/messages/TextualBody.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index 998818da20..9d999224fa 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -32,6 +32,7 @@ import { _t } from '../../../languageHandler'; import UserSettingsStore from "../../../UserSettingsStore"; import MatrixClientPeg from '../../../MatrixClientPeg'; import {RoomMember} from 'matrix-js-sdk'; +import classNames from 'classnames'; linkifyMatrix(linkify); @@ -182,13 +183,15 @@ module.exports = React.createClass({ let avatar; let roomId; let room; + let userId; let member; switch (match[1]) { case "user": roomId = this.props.mxEvent.getRoomId(); room = MatrixClientPeg.get().getRoom(roomId); - member = room.getMember(match[2]) || - new RoomMember(null, match[2]); + userId = match[2]; + member = room.getMember(userId) || + new RoomMember(null, userId); avatar = ; break; case "room": @@ -203,8 +206,15 @@ module.exports = React.createClass({ } if (avatar) { const avatarContainer = document.createElement('span'); - node.className = "mx_MTextBody_pill " + - (match[1] === "user" ? "mx_UserPill" : "mx_RoomPill"); + node.className = classNames( + "mx_MTextBody_pill", + { + "mx_UserPill": match[1] === "user", + "mx_RoomPill": match[1] === "room", + "mx_UserPill_me": + userId === MatrixClientPeg.get().credentials.userId, + }, + ); ReactDOM.render(avatar, avatarContainer); node.insertBefore(avatarContainer, node.firstChild); }