eventIds is missing

This commit is contained in:
Bruno Windels 2021-09-23 18:49:23 +02:00
parent e6f7f213ec
commit c6ed0abfd7

View file

@ -26,8 +26,9 @@ export class GapWriter {
this._fragmentIdComparer = fragmentIdComparer; this._fragmentIdComparer = fragmentIdComparer;
this._relationWriter = relationWriter; this._relationWriter = relationWriter;
} }
// events is in reverse-chronological order (last event comes at index 0) if backwards
async _findOverlappingEvents(fragmentEntry, events, txn, log) { async _findOverlappingEvents(fragmentEntry, events, txn) {
const eventIds = events.map(e => e.event_id);
const existingEventKeyMap = await txn.timelineEvents.getEventKeysForIds(this._roomId, eventIds); const existingEventKeyMap = await txn.timelineEvents.getEventKeysForIds(this._roomId, eventIds);
const nonOverlappingEvents = events.filter(e => !existingEventKeyMap.has(e.event_id)); const nonOverlappingEvents = events.filter(e => !existingEventKeyMap.has(e.event_id));
let neighbourFragmentEntry; let neighbourFragmentEntry;
@ -185,7 +186,7 @@ export class GapWriter {
const { const {
nonOverlappingEvents, nonOverlappingEvents,
neighbourFragmentEntry neighbourFragmentEntry
} = await this._findOverlappingEvents(fragmentEntry, chunk, txn, log); } = await this._findOverlappingEvents(fragmentEntry, chunk, txn);
// create entries for all events in chunk, add them to entries // create entries for all events in chunk, add them to entries
const {entries, updatedEntries} = await this._storeEvents(nonOverlappingEvents, lastKey, direction, state, txn, log); const {entries, updatedEntries} = await this._storeEvents(nonOverlappingEvents, lastKey, direction, state, txn, log);
const fragments = await this._updateFragments(fragmentEntry, neighbourFragmentEntry, end, entries, txn); const fragments = await this._updateFragments(fragmentEntry, neighbourFragmentEntry, end, entries, txn);