mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 18:25:49 +03:00
Use EntityTile for 3PID entities rather than munging MemberTile
This commit is contained in:
parent
c758c0f84f
commit
165adde0c8
2 changed files with 19 additions and 36 deletions
|
@ -285,6 +285,8 @@ module.exports = React.createClass({
|
|||
// we shouldn't add them if the 3pid invite state key (token) is in the
|
||||
// member invite (content.third_party_invite.signed.token)
|
||||
var room = MatrixClientPeg.get().getRoom(this.props.roomId);
|
||||
var EntityTile = sdk.getComponent("rooms.EntityTile");
|
||||
var BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
|
||||
if (room) {
|
||||
room.currentState.getStateEvents("m.room.third_party_invite").forEach(
|
||||
function(e) {
|
||||
|
@ -294,9 +296,12 @@ module.exports = React.createClass({
|
|||
if (memberEvent) {
|
||||
return;
|
||||
}
|
||||
var avatarJsx = (
|
||||
<BaseAvatar name={e.getContent().display_name} width={36} height={36} />
|
||||
);
|
||||
memberList.push(
|
||||
<MemberTile key={e.getStateKey()} ref={e.getStateKey()}
|
||||
customDisplayName={e.getContent().display_name} />
|
||||
<EntityTile key={e.getStateKey()} ref={e.getStateKey()}
|
||||
name={e.getContent().display_name} avatarJsx={avatarJsx} />
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ module.exports = React.createClass({
|
|||
displayName: 'MemberTile',
|
||||
|
||||
propTypes: {
|
||||
member: React.PropTypes.any, // RoomMember
|
||||
customDisplayName: React.PropTypes.string, // for 3pid invites
|
||||
member: React.PropTypes.any.isRequired, // RoomMember
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
|
@ -36,7 +35,6 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
shouldComponentUpdate: function(nextProps, nextState) {
|
||||
if (!this.props.member) { return false; } // e.g. 3pid members
|
||||
if (
|
||||
this.member_last_modified_time === undefined ||
|
||||
this.member_last_modified_time < nextProps.member.getLastModifiedTime()
|
||||
|
@ -54,8 +52,6 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
onClick: function(e) {
|
||||
if (!this.props.member) { return; } // e.g. 3pid members
|
||||
|
||||
dis.dispatch({
|
||||
action: 'view_user',
|
||||
member: this.props.member,
|
||||
|
@ -63,21 +59,11 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
_getDisplayName: function() {
|
||||
if (this.props.customDisplayName) {
|
||||
return this.props.customDisplayName;
|
||||
}
|
||||
return this.props.member.name;
|
||||
},
|
||||
|
||||
getPowerLabel: function() {
|
||||
if (!this.props.member) {
|
||||
return this._getDisplayName();
|
||||
}
|
||||
var label = this.props.member.userId;
|
||||
if (this.state.isTargetMod) {
|
||||
label += " - Mod (" + this.props.member.powerLevelNorm + "%)";
|
||||
}
|
||||
return label;
|
||||
return this.props.member.userId;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -88,11 +74,9 @@ module.exports = React.createClass({
|
|||
var member = this.props.member;
|
||||
var name = this._getDisplayName();
|
||||
var active = -1;
|
||||
var presenceState = (member && member.user) ? member.user.presence : null;
|
||||
var presenceState = member.user ? member.user.presence : null;
|
||||
|
||||
var av;
|
||||
if (member) {
|
||||
av = (
|
||||
var av = (
|
||||
<MemberAvatar member={member} width={36} height={36} />
|
||||
);
|
||||
|
||||
|
@ -105,12 +89,6 @@ module.exports = React.createClass({
|
|||
);
|
||||
}
|
||||
this.member_last_modified_time = member.getLastModifiedTime();
|
||||
}
|
||||
else {
|
||||
av = (
|
||||
<BaseAvatar name={name} width={36} height={36} />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<EntityTile {...this.props} presenceActiveAgo={active} presenceState={presenceState}
|
||||
|
|
Loading…
Reference in a new issue