Merge pull request #321 from vector-im/bwindels/fix-remote-echo-race

Fix local echo reappearing after remote echo arrived
This commit is contained in:
Bruno Windels 2021-04-08 18:43:41 +02:00 committed by GitHub
commit dce13f67dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 6 deletions

View File

@ -82,12 +82,13 @@ function showItemDetails(item, parent, itemNode) {
const parentOffset = itemStart(parent) ? `${itemStart(item) - itemStart(parent)}ms` : "none"; const parentOffset = itemStart(parent) ? `${itemStart(item) - itemStart(parent)}ms` : "none";
const expandButton = t.button("Expand recursively"); const expandButton = t.button("Expand recursively");
expandButton.addEventListener("click", () => expandResursively(itemNode.parentElement.parentElement)); expandButton.addEventListener("click", () => expandResursively(itemNode.parentElement.parentElement));
const start = itemStart(item);
const aside = t.aside([ const aside = t.aside([
t.h3(itemCaption(item)), t.h3(itemCaption(item)),
t.p([t.strong("Log level: "), logLevels[itemLevel(item)]]), t.p([t.strong("Log level: "), logLevels[itemLevel(item)]]),
t.p([t.strong("Error: "), itemError(item) ? `${itemError(item).name} ${itemError(item).stack}` : "none"]), t.p([t.strong("Error: "), itemError(item) ? `${itemError(item).name} ${itemError(item).stack}` : "none"]),
t.p([t.strong("Parent offset: "), parentOffset]), t.p([t.strong("Parent offset: "), parentOffset]),
t.p([t.strong("Start: "), new Date(itemStart(item)).toString()]), t.p([t.strong("Start: "), new Date(start).toString(), ` (${start})`]),
t.p([t.strong("Duration: "), `${itemDuration(item)}ms`]), t.p([t.strong("Duration: "), `${itemDuration(item)}ms`]),
t.p([t.strong("Child count: "), itemChildren(item) ? `${itemChildren(item).length}` : "none"]), t.p([t.strong("Child count: "), itemChildren(item) ? `${itemChildren(item).length}` : "none"]),
t.p([t.strong("Forced finish: "), (itemForcedFinish(item) || false) + ""]), t.p([t.strong("Forced finish: "), (itemForcedFinish(item) || false) + ""]),

View File

@ -36,7 +36,7 @@ export class SendQueue {
const pendingEvent = new PendingEvent({ const pendingEvent = new PendingEvent({
data, data,
remove: () => this._removeEvent(pendingEvent), remove: () => this._removeEvent(pendingEvent),
emitUpdate: () => this._pendingEvents.set(pendingEvent), emitUpdate: () => this._pendingEvents.update(pendingEvent),
attachments attachments
}); });
return pendingEvent; return pendingEvent;
@ -118,7 +118,7 @@ export class SendQueue {
} }
if (idx !== -1) { if (idx !== -1) {
const pendingEvent = this._pendingEvents.get(idx); const pendingEvent = this._pendingEvents.get(idx);
parentLog.log({l: "removeRemoteEcho", id: pendingEvent.remoteId}); parentLog.log({l: "removeRemoteEcho", queueIndex: pendingEvent.queueIndex, remoteId: event.event_id, txnId});
txn.pendingEvents.remove(pendingEvent.roomId, pendingEvent.queueIndex); txn.pendingEvents.remove(pendingEvent.roomId, pendingEvent.queueIndex);
removed.push(pendingEvent); removed.push(pendingEvent);
} }

View File

@ -76,7 +76,9 @@ export class Timeline {
replaceEntries(entries) { replaceEntries(entries) {
for (const entry of entries) { for (const entry of entries) {
this._remoteEntries.replace(entry); // this will use the comparator and thus
// check for equality using the compare method in BaseEntry
this._remoteEntries.update(entry);
} }
} }

View File

@ -41,11 +41,11 @@ export class SortedArray extends BaseObservableList {
} }
} }
replace(item) { update(item, updateParams = null) {
const idx = this.indexOf(item); const idx = this.indexOf(item);
if (idx !== -1) { if (idx !== -1) {
this._items[idx] = item; this._items[idx] = item;
this.emitUpdate(idx, item, null); this.emitUpdate(idx, item, updateParams);
} }
} }