Guard against missing members in avatars

Part of https://github.com/vector-im/riot-web/issues/11744
pull/21833/head
J. Ryan Stinnett 2020-01-13 12:29:03 +00:00 committed by David Baker
parent a3fe5bbd8c
commit 8fc85797a7
2 changed files with 12 additions and 9 deletions

View File

@ -21,14 +21,17 @@ import DMRoomMap from './utils/DMRoomMap';
module.exports = { module.exports = {
avatarUrlForMember: function(member, width, height, resizeMethod) { avatarUrlForMember: function(member, width, height, resizeMethod) {
let url = member.getAvatarUrl( let url;
MatrixClientPeg.get().getHomeserverUrl(), if (member && member.getAvatarUrl) {
Math.floor(width * window.devicePixelRatio), url = member.getAvatarUrl(
Math.floor(height * window.devicePixelRatio), MatrixClientPeg.get().getHomeserverUrl(),
resizeMethod, Math.floor(width * window.devicePixelRatio),
false, Math.floor(height * window.devicePixelRatio),
false, resizeMethod,
); false,
false,
);
}
if (!url) { if (!url) {
// member can be null here currently since on invites, the JS SDK // member can be null here currently since on invites, the JS SDK
// does not have enough info to build a RoomMember object for // does not have enough info to build a RoomMember object for

View File

@ -55,7 +55,7 @@ module.exports = createReactClass({
}, },
_getState: function(props) { _getState: function(props) {
if (props.member) { if (props.member && props.member.name) {
return { return {
name: props.member.name, name: props.member.name,
title: props.title || props.member.userId, title: props.title || props.member.userId,