Sync with Dendrite
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Cadence Ember 2020-12-15 01:05:00 +13:00
parent 879c09f70b
commit f802031848
Signed by: cadence
GPG key ID: BC1C2C61CF521B17
2 changed files with 14 additions and 5 deletions

View file

@ -193,6 +193,15 @@ class Room extends ElemJS {
}
}
getHeroes() {
if (this.data.summary) {
return this.data.summary["m.heroes"]
} else {
const me = lsm.get("mx_user_id")
return this.data.state.events.filter(e => e.type === "m.room.member" && e.content.membership === "join" && e.state_key !== me).map(e => e.state_key)
}
}
getName() {
// if the room has a name
let name = this.data.state.events.find(e => e.type === "m.room.name")
@ -205,7 +214,7 @@ class Room extends ElemJS {
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.getHeroes()
if (users && users.length) {
const usernames = users.map(mxid => this.getMemberName(mxid))
return usernames.join(", ")
@ -224,7 +233,7 @@ class Room extends ElemJS {
}
}
// if the room has no avatar set, use a member's avatar
const users = this.data.summary["m.heroes"]
const users = this.getHeroes()
if (users && users[0] && this.members.has(users[0])) {
// console.log(users[0], this.members.get(users[0]))
const userAvatar = this.members.get(users[0]).value().content.avatar_url

View file

@ -58,15 +58,15 @@ function manageSync(root) {
}
const room = store.rooms.get(id).value()
const timeline = room.timeline
if (data.state) timeline.updateStateEvents(data.state.events)
if (data.timeline) {
if (data.state && data.state.events) timeline.updateStateEvents(data.state.events)
if (data.timeline && data.timeline.events) {
if (!timeline.from) timeline.from = data.timeline.prev_batch
if (data.timeline.events.length) {
newEvents = true
timeline.updateEvents(data.timeline.events)
}
}
if (data.ephemeral) timeline.updateEphemeral(data.ephemeral.events)
if (data.ephemeral && data.ephemeral.events) timeline.updateEphemeral(data.ephemeral.events)
if (data.unread_notifications) {
timeline.updateNotificationCount(data.unread_notifications.notification_count)
notificationsChange = true