forked from mystiq/hydrogen-web
expose timeline loading error in viewmodel
This commit is contained in:
parent
8e8e22fe16
commit
2cd9c2344e
1 changed files with 15 additions and 2 deletions
|
@ -6,12 +6,18 @@ export default class RoomViewModel extends EventEmitter {
|
|||
this._room = room;
|
||||
this._timeline = null;
|
||||
this._onRoomChange = this._onRoomChange.bind(this);
|
||||
this._timelineError = null;
|
||||
}
|
||||
|
||||
async enable() {
|
||||
this._room.on("change", this._onRoomChange);
|
||||
try {
|
||||
this._timeline = await this._room.openTimeline();
|
||||
this.emit("change", "timelineEntries");
|
||||
} catch (err) {
|
||||
this._timelineError = err;
|
||||
this.emit("change", "error");
|
||||
}
|
||||
}
|
||||
|
||||
disable() {
|
||||
|
@ -33,4 +39,11 @@ export default class RoomViewModel extends EventEmitter {
|
|||
get timelineEntries() {
|
||||
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 a new issue