Fix loading desynced messages

For example, in the construct room.
princess
Cadence Ember 2 years ago
parent ea6ccc08ee
commit 9dce348a4c
Signed by: cadence
GPG Key ID: BC1C2C61CF521B17
  1. 34
      src/js/timeline.js

@ -144,22 +144,25 @@ class ReactiveTimeline extends ElemJS {
}
tryAddGroups(event, indices) {
const createGroupAt = i => {
// if (printed++ < 100) console.log("tryadd success, created group")
if (i === -1) {
// here, -1 means at the start, before the first group
i = 0 // jank but it does the trick
}
if (event.canGroup()) {
const group = new EventGroup(this, [event])
this.list.splice(i, 0, group)
this.childAt(i, group)
event.setGroup(group)
} else {
this.list.splice(i, 0, event)
this.childAt(i, event)
}
}
const success = indices.some(i => {
if (!this.list[i]) {
// if (printed++ < 100) console.log("tryadd success, created group")
if (i === -1) {
// here, -1 means at the start, before the first group
i = 0 // jank but it does the trick
}
if (event.canGroup()) {
const group = new EventGroup(this, [event])
this.list.splice(i, 0, group)
this.childAt(i, group)
event.setGroup(group)
} else {
this.list.splice(i, 0, event)
this.childAt(i, event)
}
createGroupAt(i)
return true
} else if (event.canGroup() && this.list[i] && this.list[i].canGroup() && this.list[i].data.sender === event.data.sender) {
// if (printed++ < 100) console.log("tryadd success, using existing group")
@ -167,7 +170,8 @@ class ReactiveTimeline extends ElemJS {
return true
}
})
if (!success) console.log("tryadd failure", indices, this.list.map(l => l.data.sender), event.data)
// if (!success) console.log("tryadd failure", indices, this.list.map(l => l.data.sender), event.data) // I believe all the bugs are now fixed. Lol.
if (!success) createGroupAt(indices[0])
}
removeGroup(group) {

Loading…
Cancel
Save