forked from mystiq/hydrogen-web
Ignore missing events
This commit is contained in:
parent
6a6f22047e
commit
8dc3c13a93
1 changed files with 6 additions and 5 deletions
|
@ -27,7 +27,7 @@ import {NonPersistedEventEntry} from "./entries/NonPersistedEventEntry.js";
|
||||||
import {EVENT_TYPE as MEMBER_EVENT_TYPE} from "../members/RoomMember.js";
|
import {EVENT_TYPE as MEMBER_EVENT_TYPE} from "../members/RoomMember.js";
|
||||||
|
|
||||||
export class Timeline {
|
export class Timeline {
|
||||||
constructor({roomId, storage, closeCallback, fragmentIdComparer, pendingEvents, clock, powerLevelsObservable, hsApi}) {
|
constructor({roomId, storage, closeCallback, fragmentIdComparer, pendingEvents, clock, powerLevelsObservable, hsApi, ignoreMissingEvents}) {
|
||||||
this._roomId = roomId;
|
this._roomId = roomId;
|
||||||
this._storage = storage;
|
this._storage = storage;
|
||||||
this._closeCallback = closeCallback;
|
this._closeCallback = closeCallback;
|
||||||
|
@ -50,6 +50,7 @@ export class Timeline {
|
||||||
/** Only used to decrypt non-persisted context entries fetched from the homeserver */
|
/** Only used to decrypt non-persisted context entries fetched from the homeserver */
|
||||||
this._decryptEntries = null;
|
this._decryptEntries = null;
|
||||||
this._hsApi = hsApi;
|
this._hsApi = hsApi;
|
||||||
|
this._ignoreMissingEvents = ignoreMissingEvents || false;
|
||||||
this.initializePowerLevels(powerLevelsObservable);
|
this.initializePowerLevels(powerLevelsObservable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,18 +322,18 @@ export class Timeline {
|
||||||
if (!entry.contextEventId) {
|
if (!entry.contextEventId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const id = entry.contextEventId;
|
const contextEventId = entry.contextEventId;
|
||||||
// before looking into remoteEntries, check the entries
|
// before looking into remoteEntries, check the entries
|
||||||
// that about to be added first
|
// that about to be added first
|
||||||
let contextEvent = entries.find(e => e.id === id);
|
let contextEvent = entries.find(e => e.id === contextEventId);
|
||||||
if (!contextEvent) {
|
if (!contextEvent) {
|
||||||
contextEvent = this._findLoadedEventById(id);
|
contextEvent = this._findLoadedEventById(contextEventId);
|
||||||
}
|
}
|
||||||
if (contextEvent) {
|
if (contextEvent) {
|
||||||
entry.setContextEntry(contextEvent);
|
entry.setContextEntry(contextEvent);
|
||||||
// we don't emit an update here, as the add or update
|
// we don't emit an update here, as the add or update
|
||||||
// that the callee will emit hasn't been emitted yet.
|
// that the callee will emit hasn't been emitted yet.
|
||||||
} else {
|
} else if(!this._ignoreMissingEvents) {
|
||||||
// we don't await here, which is not ideal,
|
// we don't await here, which is not ideal,
|
||||||
// but one of our callers, addEntries, is not async
|
// but one of our callers, addEntries, is not async
|
||||||
// so there is not much point.
|
// so there is not much point.
|
||||||
|
|
Loading…
Reference in a new issue