Fix undetectable race condition in open timeline
This commit is contained in:
parent
dfc84186a8
commit
a28ede2f72
1 changed files with 5 additions and 1 deletions
|
@ -47,6 +47,7 @@ export class BaseRoom extends EventEmitter {
|
||||||
this._fragmentIdComparer = new FragmentIdComparer([]);
|
this._fragmentIdComparer = new FragmentIdComparer([]);
|
||||||
this._emitCollectionChange = emitCollectionChange;
|
this._emitCollectionChange = emitCollectionChange;
|
||||||
this._timeline = null;
|
this._timeline = null;
|
||||||
|
this._openTimelinePromise = null;
|
||||||
this._user = user;
|
this._user = user;
|
||||||
this._changedMembersDuringSync = null;
|
this._changedMembersDuringSync = null;
|
||||||
this._memberList = null;
|
this._memberList = null;
|
||||||
|
@ -542,7 +543,8 @@ export class BaseRoom extends EventEmitter {
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
openTimeline(log = null) {
|
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);
|
log.set("id", this.id);
|
||||||
if (this._timeline) {
|
if (this._timeline) {
|
||||||
throw new Error("not dealing with load race here for now");
|
throw new Error("not dealing with load race here for now");
|
||||||
|
@ -554,6 +556,7 @@ export class BaseRoom extends EventEmitter {
|
||||||
pendingEvents: this._getPendingEvents(),
|
pendingEvents: this._getPendingEvents(),
|
||||||
closeCallback: () => {
|
closeCallback: () => {
|
||||||
this._timeline = null;
|
this._timeline = null;
|
||||||
|
this._openTimelinePromise = null;
|
||||||
if (this._roomEncryption) {
|
if (this._roomEncryption) {
|
||||||
this._roomEncryption.notifyTimelineClosed();
|
this._roomEncryption.notifyTimelineClosed();
|
||||||
}
|
}
|
||||||
|
@ -575,6 +578,7 @@ export class BaseRoom extends EventEmitter {
|
||||||
}
|
}
|
||||||
return this._timeline;
|
return this._timeline;
|
||||||
});
|
});
|
||||||
|
return this._openTimelinePromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allow subclasses to provide an observable list with pending events when opening the timeline */
|
/* allow subclasses to provide an observable list with pending events when opening the timeline */
|
||||||
|
|
Reference in a new issue