Room.name can actually return null now

so protect against this, and fall back to "Empty Room"
This commit is contained in:
Bruno Windels 2020-08-21 18:14:32 +02:00
parent e4758d0651
commit b39c15d88d
2 changed files with 5 additions and 5 deletions

View File

@ -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() {

View File

@ -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() {