mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Merge pull request #166 from vector-im/bwindels/fix-crash-switch-rooms-too-fast
fix a crash when switching rooms before the messages have loaded
This commit is contained in:
commit
ade4ba750f
@ -25,7 +25,6 @@ export class RoomViewModel extends ViewModel {
|
|||||||
const {room, ownUserId} = options;
|
const {room, ownUserId} = options;
|
||||||
this._room = room;
|
this._room = room;
|
||||||
this._ownUserId = ownUserId;
|
this._ownUserId = ownUserId;
|
||||||
this._timeline = null;
|
|
||||||
this._timelineVM = null;
|
this._timelineVM = null;
|
||||||
this._onRoomChange = this._onRoomChange.bind(this);
|
this._onRoomChange = this._onRoomChange.bind(this);
|
||||||
this._timelineError = null;
|
this._timelineError = null;
|
||||||
@ -42,13 +41,12 @@ export class RoomViewModel extends ViewModel {
|
|||||||
async load() {
|
async load() {
|
||||||
this._room.on("change", this._onRoomChange);
|
this._room.on("change", this._onRoomChange);
|
||||||
try {
|
try {
|
||||||
this._timeline = this.track(this._room.openTimeline());
|
this._timelineVM = this.track(new TimelineViewModel(this.childOptions({
|
||||||
await this._timeline.load();
|
|
||||||
this._timelineVM = new TimelineViewModel(this.childOptions({
|
|
||||||
room: this._room,
|
room: this._room,
|
||||||
timeline: this._timeline,
|
timeline: this._room.openTimeline(),
|
||||||
ownUserId: this._ownUserId,
|
ownUserId: this._ownUserId,
|
||||||
}));
|
})));
|
||||||
|
await this._timelineVM.load();
|
||||||
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}`);
|
||||||
|
@ -39,13 +39,17 @@ export class TimelineViewModel extends ViewModel {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
const {room, timeline, ownUserId} = options;
|
const {room, timeline, ownUserId} = options;
|
||||||
this._timeline = timeline;
|
this._timeline = this.track(timeline);
|
||||||
// once we support sending messages we could do
|
// once we support sending messages we could do
|
||||||
// timeline.entries.concat(timeline.pendingEvents)
|
// timeline.entries.concat(timeline.pendingEvents)
|
||||||
// for an ObservableList that also contains local echos
|
// for an ObservableList that also contains local echos
|
||||||
this._tiles = new TilesCollection(timeline.entries, tilesCreator({room, ownUserId, clock: this.clock}));
|
this._tiles = new TilesCollection(timeline.entries, tilesCreator({room, ownUserId, clock: this.clock}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async load() {
|
||||||
|
await this._timeline.load();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {bool} startReached if the start of the timeline was reached
|
* @return {bool} startReached if the start of the timeline was reached
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user