don't crash when we don't have a subscription anymore

This commit is contained in:
Bruno Windels 2020-09-14 17:43:06 +02:00
parent c91290fac2
commit 9ea961ae53
2 changed files with 10 additions and 0 deletions

View file

@ -25,6 +25,7 @@ export class ViewModel extends EventEmitter {
constructor({clock, emitChange} = {}) {
super();
this.disposables = null;
this._isDisposed = false;
this._options = {clock, emitChange};
}
@ -43,6 +44,11 @@ export class ViewModel extends EventEmitter {
if (this.disposables) {
this.disposables.dispose();
}
this._isDisposed = true;
}
get isDisposed() {
return this._isDisposed;
}
disposeTracked(disposable) {

View file

@ -50,6 +50,10 @@ export class TimelineViewModel extends ViewModel {
* @return {bool} startReached if the start of the timeline was reached
*/
async loadAtTop() {
if (this.isDisposed) {
// stop loading more, we switched room
return true;
}
const firstTile = this._tiles.getFirst();
if (firstTile.shape === "gap") {
return firstTile.fill();