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";
|
import {StaticView} from "../general/StaticView.js";
|
||||||
|
|
||||||
export class RoomGridView extends TemplateView {
|
export class RoomGridView extends TemplateView {
|
||||||
|
constructor(vm, viewClassForTile) {
|
||||||
|
super(vm);
|
||||||
|
this._viewClassForTile = viewClassForTile;
|
||||||
|
}
|
||||||
|
|
||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
const children = [];
|
const children = [];
|
||||||
for (let i = 0; i < (vm.height * vm.width); i+=1) {
|
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") {
|
} else if (roomVM.kind === "invite") {
|
||||||
return new InviteView(roomVM);
|
return new InviteView(roomVM);
|
||||||
} else {
|
} else {
|
||||||
return new RoomView(roomVM);
|
return new RoomView(roomVM, this._viewClassForTile);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new StaticView(t => t.div({className: "room-placeholder"}, [
|
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 {SettingsView} from "./settings/SettingsView.js";
|
||||||
import {CreateRoomView} from "./CreateRoomView.js";
|
import {CreateRoomView} from "./CreateRoomView.js";
|
||||||
import {RightPanelView} from "./rightpanel/RightPanelView.js";
|
import {RightPanelView} from "./rightpanel/RightPanelView.js";
|
||||||
|
import {viewClassForTile} from "./room/common";
|
||||||
|
|
||||||
export class SessionView extends TemplateView {
|
export class SessionView extends TemplateView {
|
||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
|
@ -42,7 +43,7 @@ export class SessionView extends TemplateView {
|
||||||
t.view(new LeftPanelView(vm.leftPanelViewModel)),
|
t.view(new LeftPanelView(vm.leftPanelViewModel)),
|
||||||
t.mapView(vm => vm.activeMiddleViewModel, () => {
|
t.mapView(vm => vm.activeMiddleViewModel, () => {
|
||||||
if (vm.roomGridViewModel) {
|
if (vm.roomGridViewModel) {
|
||||||
return new RoomGridView(vm.roomGridViewModel);
|
return new RoomGridView(vm.roomGridViewModel, viewClassForTile);
|
||||||
} else if (vm.settingsViewModel) {
|
} else if (vm.settingsViewModel) {
|
||||||
return new SettingsView(vm.settingsViewModel);
|
return new SettingsView(vm.settingsViewModel);
|
||||||
} else if (vm.createRoomViewModel) {
|
} else if (vm.createRoomViewModel) {
|
||||||
|
@ -51,7 +52,7 @@ export class SessionView extends TemplateView {
|
||||||
if (vm.currentRoomViewModel.kind === "invite") {
|
if (vm.currentRoomViewModel.kind === "invite") {
|
||||||
return new InviteView(vm.currentRoomViewModel);
|
return new InviteView(vm.currentRoomViewModel);
|
||||||
} else if (vm.currentRoomViewModel.kind === "room") {
|
} else if (vm.currentRoomViewModel.kind === "room") {
|
||||||
return new RoomView(vm.currentRoomViewModel);
|
return new RoomView(vm.currentRoomViewModel, viewClassForTile);
|
||||||
} else if (vm.currentRoomViewModel.kind === "roomBeingCreated") {
|
} else if (vm.currentRoomViewModel.kind === "roomBeingCreated") {
|
||||||
return new RoomBeingCreatedView(vm.currentRoomViewModel);
|
return new RoomBeingCreatedView(vm.currentRoomViewModel);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,11 +23,11 @@ import {TimelineLoadingView} from "./TimelineLoadingView.js";
|
||||||
import {MessageComposer} from "./MessageComposer.js";
|
import {MessageComposer} from "./MessageComposer.js";
|
||||||
import {RoomArchivedView} from "./RoomArchivedView.js";
|
import {RoomArchivedView} from "./RoomArchivedView.js";
|
||||||
import {AvatarView} from "../../AvatarView.js";
|
import {AvatarView} from "../../AvatarView.js";
|
||||||
import {viewClassForTile} from "./common";
|
|
||||||
|
|
||||||
export class RoomView extends TemplateView {
|
export class RoomView extends TemplateView {
|
||||||
constructor(options) {
|
constructor(vm, viewClassForTile) {
|
||||||
super(options);
|
super(vm);
|
||||||
|
this._viewClassForTile = viewClassForTile;
|
||||||
this._optionsPopup = null;
|
this._optionsPopup = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ export class RoomView extends TemplateView {
|
||||||
t.div({className: "RoomView_error"}, vm => vm.error),
|
t.div({className: "RoomView_error"}, vm => vm.error),
|
||||||
t.mapView(vm => vm.timelineViewModel, timelineViewModel => {
|
t.mapView(vm => vm.timelineViewModel, timelineViewModel => {
|
||||||
return timelineViewModel ?
|
return timelineViewModel ?
|
||||||
new TimelineView(timelineViewModel, viewClassForTile) :
|
new TimelineView(timelineViewModel, this._viewClassForTile) :
|
||||||
new TimelineLoadingView(vm); // vm is just needed for i18n
|
new TimelineLoadingView(vm); // vm is just needed for i18n
|
||||||
}),
|
}),
|
||||||
t.view(bottomView),
|
t.view(bottomView),
|
||||||
|
|
Loading…
Reference in a new issue