Fix loading desynced messages
All checks were successful
continuous-integration/drone/push Build is passing

For example, in the construct room.
This commit is contained in:
Cadence Ember 2020-11-30 22:40:44 +13:00
parent ea6ccc08ee
commit 9dce348a4c
Signed by: cadence
GPG key ID: BC1C2C61CF521B17

View file

@ -144,22 +144,25 @@ class ReactiveTimeline extends ElemJS {
} }
tryAddGroups(event, indices) { 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 => { const success = indices.some(i => {
if (!this.list[i]) { if (!this.list[i]) {
// if (printed++ < 100) console.log("tryadd success, created group") createGroupAt(i)
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)
}
return true return true
} else if (event.canGroup() && this.list[i] && this.list[i].canGroup() && this.list[i].data.sender === event.data.sender) { } 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") // if (printed++ < 100) console.log("tryadd success, using existing group")
@ -167,7 +170,8 @@ class ReactiveTimeline extends ElemJS {
return true 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) { removeGroup(group) {