From b39c15d88d502f3870fb3218f61e2adcdc0bd1ef Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 21 Aug 2020 18:14:32 +0200 Subject: [PATCH] Room.name can actually return null now so protect against this, and fall back to "Empty Room" --- src/domain/session/room/RoomViewModel.js | 4 ++-- src/domain/session/roomlist/RoomTileViewModel.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index b5c05be7..32e09fbe 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -84,7 +84,7 @@ export class RoomViewModel extends ViewModel { } get name() { - return this._room.name; + return this._room.name || this.i18n`Empty Room`; } get timelineViewModel() { @@ -102,7 +102,7 @@ export class RoomViewModel extends ViewModel { } get avatarLetter() { - return avatarInitials(this._room.name); + return avatarInitials(this.name); } get avatarColorNumber() { diff --git a/src/domain/session/roomlist/RoomTileViewModel.js b/src/domain/session/roomlist/RoomTileViewModel.js index 9fa7df0f..ec344f79 100644 --- a/src/domain/session/roomlist/RoomTileViewModel.js +++ b/src/domain/session/roomlist/RoomTileViewModel.js @@ -70,7 +70,7 @@ export class RoomTileViewModel extends ViewModel { const timeDiff = theirTimestamp - myTimestamp; if (timeDiff === 0) { // sort alphabetically - const nameCmp = this._room.name.localeCompare(other._room.name); + const nameCmp = this.name.localeCompare(other.name); if (nameCmp === 0) { return this._room.id.localeCompare(other._room.id); } @@ -88,12 +88,12 @@ export class RoomTileViewModel extends ViewModel { } get name() { - return this._room.name; + return this._room.name || this.i18n`Empty Room`; } // Avatar view model contract get avatarLetter() { - return avatarInitials(this._room.name); + return avatarInitials(this.name); } get avatarColorNumber() {