Don't break on rooms with a redacted name
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a7ded5fae3
commit
64c3e18788
1 changed files with 12 additions and 7 deletions
|
@ -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 {
|
||||
if (name && name.content.name) {
|
||||
return name.content.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)
|
||||
name = usernames.join(", ")
|
||||
}
|
||||
return name
|
||||
return usernames.join(", ")
|
||||
}
|
||||
|
||||
getIcon() {
|
||||
|
|
Loading…
Reference in a new issue