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() {
|
getName() {
|
||||||
|
// if the room has a name
|
||||||
let name = this.data.state.events.find(e => e.type === "m.room.name")
|
let name = this.data.state.events.find(e => e.type === "m.room.name")
|
||||||
if (name) {
|
if (name && name.content.name) {
|
||||||
name = name.content.name
|
return name.content.name
|
||||||
} else {
|
}
|
||||||
|
// 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 users = this.data.summary["m.heroes"]
|
||||||
const usernames = users.map(u => (u.match(/^@([^:]+):/) || [])[1] || u)
|
const usernames = users.map(u => (u.match(/^@([^:]+):/) || [])[1] || u)
|
||||||
name = usernames.join(", ")
|
return usernames.join(", ")
|
||||||
}
|
|
||||||
return name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getIcon() {
|
getIcon() {
|
||||||
|
|
Loading…
Reference in a new issue