mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Move context fetching into BaseRoom
This commit is contained in:
parent
5b868a9064
commit
2501bad4b4
@ -311,6 +311,22 @@ export class BaseRoom extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _fetchContext(eventId, log = null) {
|
||||||
|
const response = await this._hsApi.context(this._roomId, eventId, {}, {log}).response();
|
||||||
|
let contextEvent = null;
|
||||||
|
await this._fetchEvents(async (txn, gapWriter) => {
|
||||||
|
// Just in case we somehow receive remote echoes during event fetch
|
||||||
|
// Keep events in order just in case.
|
||||||
|
const allEvents = response.events_before.slice().reverse();
|
||||||
|
allEvents.push(response.event, ...response.events_after);
|
||||||
|
const extraGapFillChanges = await this._writeGapFill(allEvents, txn, log);
|
||||||
|
const gapResult = await gapWriter.writeContext(response, txn, log);
|
||||||
|
contextEvent = gapResult.contextEvent;
|
||||||
|
return { extraGapFillChanges, gapResult };
|
||||||
|
}, log);
|
||||||
|
return contextEvent;
|
||||||
|
}
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
fillGap(fragmentEntry, amount, log = null) {
|
fillGap(fragmentEntry, amount, log = null) {
|
||||||
// TODO move some/all of this out of BaseRoom
|
// TODO move some/all of this out of BaseRoom
|
||||||
|
@ -110,22 +110,6 @@ export class Room extends BaseRoom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _fetchContext(eventId, log = null) {
|
|
||||||
const response = await this._hsApi.context(this._roomId, eventId, {}, {log}).response();
|
|
||||||
let contextEvent = null;
|
|
||||||
await this._fetchEvents(async (txn, gapWriter) => {
|
|
||||||
// Just in case we somehow receive remote echoes during event fetch
|
|
||||||
// Keep events in order just in case.
|
|
||||||
const allEvents = response.events_before.slice().reverse();
|
|
||||||
allEvents.push(response.event, ...response.events_after);
|
|
||||||
const extraGapFillChanges = await this._writeGapFill(allEvents, txn, log);
|
|
||||||
const gapResult = await gapWriter.writeContext(response, txn, log);
|
|
||||||
contextEvent = gapResult.contextEvent;
|
|
||||||
return { extraGapFillChanges, gapResult };
|
|
||||||
}, log);
|
|
||||||
return contextEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @package */
|
/** @package */
|
||||||
async writeSync(roomResponse, isInitialSync, {summaryChanges, decryptChanges, roomEncryption, retryEntries}, txn, log) {
|
async writeSync(roomResponse, isInitialSync, {summaryChanges, decryptChanges, roomEncryption, retryEntries}, txn, log) {
|
||||||
log.set("id", this.id);
|
log.set("id", this.id);
|
||||||
|
Loading…
Reference in New Issue
Block a user