forked from mystiq/hydrogen-web
Only call room-specific gap filling hooks once
This commit is contained in:
parent
889f4dd104
commit
5b868a9064
1 changed files with 6 additions and 5 deletions
|
@ -110,17 +110,18 @@ export class Room extends BaseRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchContext(eventId, log = null) {
|
async _fetchContext(eventId, log = null) {
|
||||||
const response = await this._hsApi.context(this._roomId, eventId, {}, {log}).response();
|
const response = await this._hsApi.context(this._roomId, eventId, {}, {log}).response();
|
||||||
let contextEvent = null;
|
let contextEvent = null;
|
||||||
await this._fetchEvents(async (txn, gapWriter) => {
|
await this._fetchEvents(async (txn, gapWriter) => {
|
||||||
// Just in case we somehow receive remote echoes during event fetch
|
// Just in case we somehow receive remote echoes during event fetch
|
||||||
const beforeExtra = await this._writeGapFill(response.events_before, txn, log);
|
// Keep events in order just in case.
|
||||||
const afterExtra = await this._writeGapFill(response.events_after, txn, log);
|
const allEvents = response.events_before.slice().reverse();
|
||||||
beforeExtra.push(...afterExtra);
|
allEvents.push(response.event, ...response.events_after);
|
||||||
|
const extraGapFillChanges = await this._writeGapFill(allEvents, txn, log);
|
||||||
const gapResult = await gapWriter.writeContext(response, txn, log);
|
const gapResult = await gapWriter.writeContext(response, txn, log);
|
||||||
contextEvent = gapResult.contextEvent;
|
contextEvent = gapResult.contextEvent;
|
||||||
return { extraGapFillChanges: beforeExtra, gapResult };
|
return { extraGapFillChanges, gapResult };
|
||||||
}, log);
|
}, log);
|
||||||
return contextEvent;
|
return contextEvent;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue