Don't break on rooms with a redacted name
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Cadence Ember 2020-10-21 22:10:58 +13:00
parent a7ded5fae3
commit 64c3e18788
Signed by: cadence
GPG key ID: BC1C2C61CF521B17

View file

@ -94,15 +94,20 @@ class Room extends ElemJS {
}
getName() {
// if the room has a name
let name = this.data.state.events.find(e => e.type === "m.room.name")
if (name) {
name = name.content.name
} else {
const users = this.data.summary["m.heroes"]
const usernames = users.map(u => (u.match(/^@([^:]+):/) || [])[1] || u)
name = usernames.join(", ")
if (name && name.content.name) {
return name.content.name
}
return name
// if the room has no name, use its canonical alias
let canonicalAlias = this.data.state.events.find(e => e.type === "m.room.canonical_alias")
if (canonicalAlias && canonicalAlias.content.alias) {
return canonicalAlias.content.alias
}
// if the room has no alias, use the names of its members ("heroes")
const users = this.data.summary["m.heroes"]
const usernames = users.map(u => (u.match(/^@([^:]+):/) || [])[1] || u)
return usernames.join(", ")
}
getIcon() {