diff --git a/src/Avatar.js b/src/Avatar.js index 5a330c31e9..217b196348 100644 --- a/src/Avatar.js +++ b/src/Avatar.js @@ -102,6 +102,8 @@ export function getInitialLetter(name) { } export function avatarUrlForRoom(room, width, height, resizeMethod) { + if (!room) return null; // null-guard + const explicitRoomAvatar = room.getAvatarUrl( MatrixClientPeg.get().getHomeserverUrl(), width, diff --git a/src/editor/parts.js b/src/editor/parts.js index 652342405f..8bb4f8633e 100644 --- a/src/editor/parts.js +++ b/src/editor/parts.js @@ -254,8 +254,8 @@ class RoomPillPart extends PillPart { let initialLetter = ""; let avatarUrl = Avatar.avatarUrlForRoom(this._room, 16 * window.devicePixelRatio, 16 * window.devicePixelRatio); if (!avatarUrl) { - initialLetter = Avatar.getInitialLetter(this._room.name); - avatarUrl = `../../${Avatar.defaultAvatarUrlForString(this._room.roomId)}`; + initialLetter = Avatar.getInitialLetter(this._room ? this._room.name : this.resourceId); + avatarUrl = `../../${Avatar.defaultAvatarUrlForString(this._room ? this._room.roomId : this.resourceId)}`; } this._setAvatarVars(node, avatarUrl, initialLetter); }