diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index 2d401a65..4b6fccd7 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -300,9 +300,7 @@ export class BaseRoom extends EventEmitter { await decryptRequest.complete(); } // once txn is committed, update in-memory state & emit events - for (const fragment of gapResult.fragments) { - this._fragmentIdComparer.add(fragment); - } + this._fragmentIdComparer.add(...gapResult.fragments); if (extraGapFillChanges) { this._applyGapFill(extraGapFillChanges); } diff --git a/src/matrix/room/timeline/FragmentIdComparer.js b/src/matrix/room/timeline/FragmentIdComparer.js index fcd27edf..ec564b51 100644 --- a/src/matrix/room/timeline/FragmentIdComparer.js +++ b/src/matrix/room/timeline/FragmentIdComparer.js @@ -171,9 +171,11 @@ export class FragmentIdComparer { } /** use for fragments coming out of persistence, not newly created ones, or also fragments for a new island (like for a permalink) */ - add(fragment) { - const copy = new Fragment(fragment.id, fragment.previousId, fragment.nextId); - this._fragmentsById.set(fragment.id, copy); + add(...fragments) { + for (const fragment of fragments) { + const copy = new Fragment(fragment.id, fragment.previousId, fragment.nextId); + this._fragmentsById.set(fragment.id, copy); + } this.rebuild(this._fragmentsById.values()); }