Allow simultaneous adds

This commit is contained in:
Danila Fedorin 2021-09-08 14:10:20 -07:00
parent 1b6fea6e4d
commit 021844bf0a
2 changed files with 6 additions and 6 deletions

View File

@ -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);
}

View File

@ -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());
}