mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-30 23:31:28 +03:00
Add mx_UserPill_me class to user pills that match credentials.userId
This commit is contained in:
parent
29757fcf11
commit
b131637a11
1 changed files with 14 additions and 4 deletions
|
@ -32,6 +32,7 @@ import { _t } from '../../../languageHandler';
|
||||||
import UserSettingsStore from "../../../UserSettingsStore";
|
import UserSettingsStore from "../../../UserSettingsStore";
|
||||||
import MatrixClientPeg from '../../../MatrixClientPeg';
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
import {RoomMember} from 'matrix-js-sdk';
|
import {RoomMember} from 'matrix-js-sdk';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
linkifyMatrix(linkify);
|
linkifyMatrix(linkify);
|
||||||
|
|
||||||
|
@ -182,13 +183,15 @@ module.exports = React.createClass({
|
||||||
let avatar;
|
let avatar;
|
||||||
let roomId;
|
let roomId;
|
||||||
let room;
|
let room;
|
||||||
|
let userId;
|
||||||
let member;
|
let member;
|
||||||
switch (match[1]) {
|
switch (match[1]) {
|
||||||
case "user":
|
case "user":
|
||||||
roomId = this.props.mxEvent.getRoomId();
|
roomId = this.props.mxEvent.getRoomId();
|
||||||
room = MatrixClientPeg.get().getRoom(roomId);
|
room = MatrixClientPeg.get().getRoom(roomId);
|
||||||
member = room.getMember(match[2]) ||
|
userId = match[2];
|
||||||
new RoomMember(null, match[2]);
|
member = room.getMember(userId) ||
|
||||||
|
new RoomMember(null, userId);
|
||||||
avatar = <MemberAvatar member={member} width={16} height={16} name={match[2]}/>;
|
avatar = <MemberAvatar member={member} width={16} height={16} name={match[2]}/>;
|
||||||
break;
|
break;
|
||||||
case "room":
|
case "room":
|
||||||
|
@ -203,8 +206,15 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
if (avatar) {
|
if (avatar) {
|
||||||
const avatarContainer = document.createElement('span');
|
const avatarContainer = document.createElement('span');
|
||||||
node.className = "mx_MTextBody_pill " +
|
node.className = classNames(
|
||||||
(match[1] === "user" ? "mx_UserPill" : "mx_RoomPill");
|
"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);
|
ReactDOM.render(avatar, avatarContainer);
|
||||||
node.insertBefore(avatarContainer, node.firstChild);
|
node.insertBefore(avatarContainer, node.firstChild);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue