mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
expose timeline loading error in viewmodel
This commit is contained in:
parent
8e8e22fe16
commit
2cd9c2344e
@ -6,12 +6,18 @@ export default class RoomViewModel extends EventEmitter {
|
|||||||
this._room = room;
|
this._room = room;
|
||||||
this._timeline = null;
|
this._timeline = null;
|
||||||
this._onRoomChange = this._onRoomChange.bind(this);
|
this._onRoomChange = this._onRoomChange.bind(this);
|
||||||
|
this._timelineError = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async enable() {
|
async enable() {
|
||||||
this._room.on("change", this._onRoomChange);
|
this._room.on("change", this._onRoomChange);
|
||||||
this._timeline = await this._room.openTimeline();
|
try {
|
||||||
this.emit("change", "timelineEntries");
|
this._timeline = await this._room.openTimeline();
|
||||||
|
this.emit("change", "timelineEntries");
|
||||||
|
} catch (err) {
|
||||||
|
this._timelineError = err;
|
||||||
|
this.emit("change", "error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
@ -33,4 +39,11 @@ export default class RoomViewModel extends EventEmitter {
|
|||||||
get timelineEntries() {
|
get timelineEntries() {
|
||||||
return this._timeline && this._timeline.entries;
|
return this._timeline && this._timeline.entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get error() {
|
||||||
|
if (this._timelineError) {
|
||||||
|
return `Something went wrong loading the timeline: ${this._timelineError.message}`;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user