mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
use t.view for room sub views
also move composer to own vm
This commit is contained in:
parent
28bed56b5a
commit
d7a8b1616a
@ -14,6 +14,7 @@ export class RoomViewModel extends ViewModel {
|
|||||||
this._timelineError = null;
|
this._timelineError = null;
|
||||||
this._sendError = null;
|
this._sendError = null;
|
||||||
this._closeCallback = closeCallback;
|
this._closeCallback = closeCallback;
|
||||||
|
this._composerVM = new ComposerViewModel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
@ -73,7 +74,9 @@ export class RoomViewModel extends ViewModel {
|
|||||||
return avatarInitials(this._room.name);
|
return avatarInitials(this._room.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendMessage(message) {
|
|
||||||
|
|
||||||
|
async _sendMessage(message) {
|
||||||
if (message) {
|
if (message) {
|
||||||
try {
|
try {
|
||||||
await this._room.sendEvent("m.room.message", {msgtype: "m.text", body: message});
|
await this._room.sendEvent("m.room.message", {msgtype: "m.text", body: message});
|
||||||
@ -88,4 +91,18 @@ export class RoomViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get composerViewModel() {
|
||||||
|
return this._composerVM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ComposerViewModel {
|
||||||
|
constructor(roomVM) {
|
||||||
|
this._roomVM = roomVM;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage(message) {
|
||||||
|
return this._roomVM._sendMessage(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ export class RoomView extends TemplateView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
|
this._timelineList = new TimelineList();
|
||||||
return t.div({className: "RoomView"}, [
|
return t.div({className: "RoomView"}, [
|
||||||
t.div({className: "TimelinePanel"}, [
|
t.div({className: "TimelinePanel"}, [
|
||||||
t.div({className: "RoomHeader"}, [
|
t.div({className: "RoomHeader"}, [
|
||||||
@ -19,24 +20,12 @@ export class RoomView extends TemplateView {
|
|||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
t.div({className: "RoomView_error"}, vm => vm.error),
|
t.div({className: "RoomView_error"}, vm => vm.error),
|
||||||
this._timelineList.mount(),
|
t.view(this._timelineList),
|
||||||
this._composer.mount(),
|
t.view(new MessageComposer(this.value.composerViewModel)),
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mount() {
|
|
||||||
this._composer = new MessageComposer(this.value);
|
|
||||||
this._timelineList = new TimelineList();
|
|
||||||
return super.mount();
|
|
||||||
}
|
|
||||||
|
|
||||||
unmount() {
|
|
||||||
this._composer.unmount();
|
|
||||||
this._timelineList.unmount();
|
|
||||||
super.unmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
update(value, prop) {
|
update(value, prop) {
|
||||||
super.update(value, prop);
|
super.update(value, prop);
|
||||||
if (prop === "timelineViewModel") {
|
if (prop === "timelineViewModel") {
|
||||||
|
Loading…
Reference in New Issue
Block a user