forked from mystiq/hydrogen-web
Merge pull request #844 from vector-im/bug/openTimeline-race
Fix undetectable race condition in open timeline
This commit is contained in:
commit
4dd42ce164
1 changed files with 5 additions and 1 deletions
|
@ -47,6 +47,7 @@ export class BaseRoom extends EventEmitter {
|
|||
this._fragmentIdComparer = new FragmentIdComparer([]);
|
||||
this._emitCollectionChange = emitCollectionChange;
|
||||
this._timeline = null;
|
||||
this._openTimelinePromise = null;
|
||||
this._user = user;
|
||||
this._changedMembersDuringSync = null;
|
||||
this._memberList = null;
|
||||
|
@ -542,7 +543,8 @@ export class BaseRoom extends EventEmitter {
|
|||
|
||||
/** @public */
|
||||
openTimeline(log = null) {
|
||||
return this._platform.logger.wrapOrRun(log, "open timeline", async log => {
|
||||
if (this._openTimelinePromise) return this._openTimelinePromise;
|
||||
this._openTimelinePromise = this._platform.logger.wrapOrRun(log, "open timeline", async log => {
|
||||
log.set("id", this.id);
|
||||
if (this._timeline) {
|
||||
throw new Error("not dealing with load race here for now");
|
||||
|
@ -554,6 +556,7 @@ export class BaseRoom extends EventEmitter {
|
|||
pendingEvents: this._getPendingEvents(),
|
||||
closeCallback: () => {
|
||||
this._timeline = null;
|
||||
this._openTimelinePromise = null;
|
||||
if (this._roomEncryption) {
|
||||
this._roomEncryption.notifyTimelineClosed();
|
||||
}
|
||||
|
@ -575,6 +578,7 @@ export class BaseRoom extends EventEmitter {
|
|||
}
|
||||
return this._timeline;
|
||||
});
|
||||
return this._openTimelinePromise;
|
||||
}
|
||||
|
||||
/* allow subclasses to provide an observable list with pending events when opening the timeline */
|
||||
|
|
Loading…
Reference in a new issue