forked from mystiq/hydrogen-web
pass in viewClassForTile from SessionView
so you can also use custom tiles when using the grid view
This commit is contained in:
parent
1fea14dd10
commit
d21d10e4f2
3 changed files with 13 additions and 7 deletions
|
@ -21,6 +21,11 @@ import {TemplateView} from "../general/TemplateView";
|
|||
import {StaticView} from "../general/StaticView.js";
|
||||
|
||||
export class RoomGridView extends TemplateView {
|
||||
constructor(vm, viewClassForTile) {
|
||||
super(vm);
|
||||
this._viewClassForTile = viewClassForTile;
|
||||
}
|
||||
|
||||
render(t, vm) {
|
||||
const children = [];
|
||||
for (let i = 0; i < (vm.height * vm.width); i+=1) {
|
||||
|
@ -39,7 +44,7 @@ export class RoomGridView extends TemplateView {
|
|||
} else if (roomVM.kind === "invite") {
|
||||
return new InviteView(roomVM);
|
||||
} else {
|
||||
return new RoomView(roomVM);
|
||||
return new RoomView(roomVM, this._viewClassForTile);
|
||||
}
|
||||
} else {
|
||||
return new StaticView(t => t.div({className: "room-placeholder"}, [
|
||||
|
|
|
@ -28,6 +28,7 @@ import {RoomGridView} from "./RoomGridView.js";
|
|||
import {SettingsView} from "./settings/SettingsView.js";
|
||||
import {CreateRoomView} from "./CreateRoomView.js";
|
||||
import {RightPanelView} from "./rightpanel/RightPanelView.js";
|
||||
import {viewClassForTile} from "./room/common";
|
||||
|
||||
export class SessionView extends TemplateView {
|
||||
render(t, vm) {
|
||||
|
@ -42,7 +43,7 @@ export class SessionView extends TemplateView {
|
|||
t.view(new LeftPanelView(vm.leftPanelViewModel)),
|
||||
t.mapView(vm => vm.activeMiddleViewModel, () => {
|
||||
if (vm.roomGridViewModel) {
|
||||
return new RoomGridView(vm.roomGridViewModel);
|
||||
return new RoomGridView(vm.roomGridViewModel, viewClassForTile);
|
||||
} else if (vm.settingsViewModel) {
|
||||
return new SettingsView(vm.settingsViewModel);
|
||||
} else if (vm.createRoomViewModel) {
|
||||
|
@ -51,7 +52,7 @@ export class SessionView extends TemplateView {
|
|||
if (vm.currentRoomViewModel.kind === "invite") {
|
||||
return new InviteView(vm.currentRoomViewModel);
|
||||
} else if (vm.currentRoomViewModel.kind === "room") {
|
||||
return new RoomView(vm.currentRoomViewModel);
|
||||
return new RoomView(vm.currentRoomViewModel, viewClassForTile);
|
||||
} else if (vm.currentRoomViewModel.kind === "roomBeingCreated") {
|
||||
return new RoomBeingCreatedView(vm.currentRoomViewModel);
|
||||
} else {
|
||||
|
|
|
@ -23,11 +23,11 @@ import {TimelineLoadingView} from "./TimelineLoadingView.js";
|
|||
import {MessageComposer} from "./MessageComposer.js";
|
||||
import {RoomArchivedView} from "./RoomArchivedView.js";
|
||||
import {AvatarView} from "../../AvatarView.js";
|
||||
import {viewClassForTile} from "./common";
|
||||
|
||||
export class RoomView extends TemplateView {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
constructor(vm, viewClassForTile) {
|
||||
super(vm);
|
||||
this._viewClassForTile = viewClassForTile;
|
||||
this._optionsPopup = null;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ export class RoomView extends TemplateView {
|
|||
t.div({className: "RoomView_error"}, vm => vm.error),
|
||||
t.mapView(vm => vm.timelineViewModel, timelineViewModel => {
|
||||
return timelineViewModel ?
|
||||
new TimelineView(timelineViewModel, viewClassForTile) :
|
||||
new TimelineView(timelineViewModel, this._viewClassForTile) :
|
||||
new TimelineLoadingView(vm); // vm is just needed for i18n
|
||||
}),
|
||||
t.view(bottomView),
|
||||
|
|
Loading…
Reference in a new issue