writing relations is async

This commit is contained in:
Bruno Windels 2021-05-20 11:44:45 +02:00
parent 814e92ad92
commit 94b0bc82ef

View file

@ -105,7 +105,7 @@ export class GapWriter {
}
}
_storeEvents(events, startKey, direction, state, txn) {
async _storeEvents(events, startKey, direction, state, txn) {
const entries = [];
const updatedEntries = [];
// events is in reverse chronological order for backwards pagination,
@ -123,7 +123,7 @@ export class GapWriter {
txn.timelineEvents.insert(eventStorageEntry);
const eventEntry = new EventEntry(eventStorageEntry, this._fragmentIdComparer);
directionalAppend(entries, eventEntry, direction);
const updatedRelationTargetEntry = this._relationWriter.writeRelation(eventEntry);
const updatedRelationTargetEntry = await this._relationWriter.writeRelation(eventEntry);
if (updatedRelationTargetEntry) {
updatedEntries.push(updatedRelationTargetEntry);
}
@ -246,7 +246,7 @@ export class GapWriter {
end = null;
}
// create entries for all events in chunk, add them to entries
const {entries, updatedEntries} = this._storeEvents(nonOverlappingEvents, lastKey, direction, state, txn);
const {entries, updatedEntries} = await this._storeEvents(nonOverlappingEvents, lastKey, direction, state, txn);
const fragments = await this._updateFragments(fragmentEntry, neighbourFragmentEntry, end, entries, txn);
return {entries, updatedEntries, fragments};