export timelineviewmodel from roomviewmodel

This commit is contained in:
Bruno Windels 2019-06-01 18:29:23 +02:00
parent 039bbe038c
commit 1b228b0200

View File

@ -1,10 +1,12 @@
import EventEmitter from "../../../EventEmitter.js"; import EventEmitter from "../../../EventEmitter.js";
import TimelineViewModel from "./timeline/TimelineViewModel.js";
export default class RoomViewModel extends EventEmitter { export default class RoomViewModel extends EventEmitter {
constructor(room) { constructor(room) {
super(); super();
this._room = room; this._room = room;
this._timeline = null; this._timeline = null;
this._timelineVM = null;
this._onRoomChange = this._onRoomChange.bind(this); this._onRoomChange = this._onRoomChange.bind(this);
this._timelineError = null; this._timelineError = null;
} }
@ -13,6 +15,7 @@ export default class RoomViewModel extends EventEmitter {
this._room.on("change", this._onRoomChange); this._room.on("change", this._onRoomChange);
try { try {
this._timeline = await this._room.openTimeline(); this._timeline = await this._room.openTimeline();
this._timelineVM = new TimelineViewModel(this._timeline);
this.emit("change", "timelineEntries"); this.emit("change", "timelineEntries");
} catch (err) { } catch (err) {
this._timelineError = err; this._timelineError = err;
@ -22,6 +25,7 @@ export default class RoomViewModel extends EventEmitter {
disable() { disable() {
if (this._timeline) { if (this._timeline) {
// will stop the timeline from delivering updates on entries
this._timeline.close(); this._timeline.close();
} }
} }
@ -36,8 +40,8 @@ export default class RoomViewModel extends EventEmitter {
return this._room.name; return this._room.name;
} }
get timelineEntries() { get timelineViewModel() {
return this._timeline && this._timeline.entries; return this._timelineVM;
} }
get error() { get error() {