mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Apply null-guard to room pills for when we can't fetch the room
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
744826db48
commit
e799691573
2 changed files with 4 additions and 2 deletions
|
@ -102,6 +102,8 @@ export function getInitialLetter(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function avatarUrlForRoom(room, width, height, resizeMethod) {
|
export function avatarUrlForRoom(room, width, height, resizeMethod) {
|
||||||
|
if (!room) return null; // null-guard
|
||||||
|
|
||||||
const explicitRoomAvatar = room.getAvatarUrl(
|
const explicitRoomAvatar = room.getAvatarUrl(
|
||||||
MatrixClientPeg.get().getHomeserverUrl(),
|
MatrixClientPeg.get().getHomeserverUrl(),
|
||||||
width,
|
width,
|
||||||
|
|
|
@ -254,8 +254,8 @@ class RoomPillPart extends PillPart {
|
||||||
let initialLetter = "";
|
let initialLetter = "";
|
||||||
let avatarUrl = Avatar.avatarUrlForRoom(this._room, 16 * window.devicePixelRatio, 16 * window.devicePixelRatio);
|
let avatarUrl = Avatar.avatarUrlForRoom(this._room, 16 * window.devicePixelRatio, 16 * window.devicePixelRatio);
|
||||||
if (!avatarUrl) {
|
if (!avatarUrl) {
|
||||||
initialLetter = Avatar.getInitialLetter(this._room.name);
|
initialLetter = Avatar.getInitialLetter(this._room ? this._room.name : this.resourceId);
|
||||||
avatarUrl = `../../${Avatar.defaultAvatarUrlForString(this._room.roomId)}`;
|
avatarUrl = `../../${Avatar.defaultAvatarUrlForString(this._room ? this._room.roomId : this.resourceId)}`;
|
||||||
}
|
}
|
||||||
this._setAvatarVars(node, avatarUrl, initialLetter);
|
this._setAvatarVars(node, avatarUrl, initialLetter);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue