bring back old behaviour to also show member avatars if not marked as 1:1 room

pull/21833/head
Bruno Windels 2018-08-27 18:48:21 +02:00
parent 36665d3c69
commit 6a077655e9
1 changed files with 29 additions and 14 deletions

View File

@ -108,23 +108,38 @@ module.exports = React.createClass({
}, },
getOneToOneAvatar: function(props) { getOneToOneAvatar: function(props) {
if (!props.room) return null; const room = props.room;
if (!room) {
return null;
}
let otherMember = null;
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
if (otherUserId) {
otherMember = room.getMember(otherUserId);
} else {
// if the room is not marked as a 1:1, but only has max 2 members
// then still try to show any avatar (pref. other member)
const totalMemberCount = room.getJoinedMemberCount() +
room.getInvitedMemberCount();
const members = room.currentState.getMembers();
if (totalMemberCount == 2) {
const myUserId = MatrixClientPeg.get().getUserId();
otherMember = members.find(m => m.userId !== myUserId);
} else if(totalMemberCount == 1) {
otherMember = members[0];
}
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(props.room.roomId);
if (!otherUserId) {
return null;
} }
const otherMember = props.room.getMember(otherUserId); if (otherMember) {
if (!otherMember) { return otherMember.getAvatarUrl(
return null; MatrixClientPeg.get().getHomeserverUrl(),
Math.floor(props.width * window.devicePixelRatio),
Math.floor(props.height * window.devicePixelRatio),
props.resizeMethod,
false,
);
} }
return otherMember.getAvatarUrl( return null;
MatrixClientPeg.get().getHomeserverUrl(),
Math.floor(props.width * window.devicePixelRatio),
Math.floor(props.height * window.devicePixelRatio),
props.resizeMethod,
false,
);
}, },
onRoomAvatarClick: function() { onRoomAvatarClick: function() {