don't assign timelineVM before loaded, so prop doesn't return it

... if the binding happens to be evaluating (which it was during mount)

follow-up from bwindels/fix-crash-switch-rooms-too-fast
This commit is contained in:
Bruno Windels 2020-10-19 13:39:19 +02:00
parent f07b4a6554
commit 6bf8e976cb

View file

@ -41,12 +41,13 @@ export class RoomViewModel extends ViewModel {
async load() { async load() {
this._room.on("change", this._onRoomChange); this._room.on("change", this._onRoomChange);
try { try {
this._timelineVM = this.track(new TimelineViewModel(this.childOptions({ const timelineVM = this.track(new TimelineViewModel(this.childOptions({
room: this._room, room: this._room,
timeline: this._room.openTimeline(), timeline: this._room.openTimeline(),
ownUserId: this._ownUserId, ownUserId: this._ownUserId,
}))); })));
await this._timelineVM.load(); await timelineVM.load();
this._timelineVM = timelineVM;
this.emitChange("timelineViewModel"); this.emitChange("timelineViewModel");
} catch (err) { } catch (err) {
console.error(`room.openTimeline(): ${err.message}:\n${err.stack}`); console.error(`room.openTimeline(): ${err.message}:\n${err.stack}`);