Add view and vm for RoomInformation

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-05-23 15:49:31 +05:30
parent e4a1c99615
commit c7ba472042
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,25 @@
import { ViewModel } from "../../ViewModel.js";
export class RoomInfoViewModel extends ViewModel {
constructor(options) {
super(options);
this._room = options.room;
this._roomSummary = this._room._summary._data;
}
get roomId() {
return this._room.id;
}
get name() {
return this._roomSummary.name || this._room._heroes._roomName;
}
get isEncrypted() {
return !!this._roomSummary.encryption;
}
get memberCount() {
return this._roomSummary.joinCount;
}
}

View file

@ -0,0 +1,13 @@
import { TemplateView } from "../../general/TemplateView.js";
import { text } from "../../general/html.js";
export class RoomInfoView extends TemplateView {
render(t, vm) {
return t.div({ className: "RoomInfo" }, [
t.div({ className: "RoomName" }, [text(vm.name)]),
t.div({ className: "RoomId" }, [text(vm.roomId)]),
t.div({ className: "RoomMemberCount" }, [text(vm.memberCount)]),
t.div({ className: "RoomEncryption" }, [vm.isEncrypted ? "Encrypted" : "Not Encrypted"])
]);
}
}