forked from mystiq/hydrogen-web
rename viewClassForEntry to viewClassForTile
This commit is contained in:
parent
e977a6829b
commit
cda96a35ee
6 changed files with 13 additions and 13 deletions
|
@ -44,7 +44,7 @@ export {MissingAttachmentTile} from "./domain/session/room/timeline/tiles/Missin
|
|||
export {SimpleTile} from "./domain/session/room/timeline/tiles/SimpleTile.js";
|
||||
|
||||
export {TimelineView} from "./platform/web/ui/session/room/TimelineView";
|
||||
export {viewClassForEntry} from "./platform/web/ui/session/room/common";
|
||||
export {viewClassForTile} from "./platform/web/ui/session/room/common";
|
||||
export type {TileViewConstructor, ViewClassForEntryFn} from "./platform/web/ui/session/room/TimelineView";
|
||||
// export timeline tile views
|
||||
export {AnnouncementView} from "./platform/web/ui/session/room/timeline/AnnouncementView.js";
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import {TemplateView} from "../../general/TemplateView";
|
||||
import {Popup} from "../../general/Popup.js";
|
||||
import {Menu} from "../../general/Menu.js";
|
||||
import {viewClassForEntry} from "./common"
|
||||
import {viewClassForTile} from "./common"
|
||||
|
||||
export class MessageComposer extends TemplateView {
|
||||
constructor(viewModel) {
|
||||
|
@ -45,7 +45,7 @@ export class MessageComposer extends TemplateView {
|
|||
this._focusInput = () => this._input.focus();
|
||||
this.value.on("focus", this._focusInput);
|
||||
const replyPreview = t.map(vm => vm.replyViewModel, (rvm, t) => {
|
||||
const View = rvm && viewClassForEntry(rvm);
|
||||
const View = rvm && viewClassForTile(rvm);
|
||||
if (!View) { return null; }
|
||||
return t.div({
|
||||
className: "MessageComposer_replyPreview"
|
||||
|
|
|
@ -23,7 +23,7 @@ import {TimelineLoadingView} from "./TimelineLoadingView.js";
|
|||
import {MessageComposer} from "./MessageComposer.js";
|
||||
import {RoomArchivedView} from "./RoomArchivedView.js";
|
||||
import {AvatarView} from "../../AvatarView.js";
|
||||
import {viewClassForEntry} from "./common";
|
||||
import {viewClassForTile} from "./common";
|
||||
|
||||
export class RoomView extends TemplateView {
|
||||
constructor(options) {
|
||||
|
@ -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, viewClassForEntry) :
|
||||
new TimelineView(timelineViewModel, viewClassForTile) :
|
||||
new TimelineLoadingView(vm); // vm is just needed for i18n
|
||||
}),
|
||||
t.view(bottomView),
|
||||
|
|
|
@ -61,7 +61,7 @@ export class TimelineView extends TemplateView<TimelineViewModel> {
|
|||
private tilesView?: TilesListView;
|
||||
private resizeObserver?: ResizeObserver;
|
||||
|
||||
constructor(vm: TimelineViewModel, private readonly viewClassForEntry: ViewClassForEntryFn) {
|
||||
constructor(vm: TimelineViewModel, private readonly viewClassForTile: ViewClassForEntryFn) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ export class TimelineView extends TemplateView<TimelineViewModel> {
|
|||
// do initial scroll positioning
|
||||
this.restoreScrollPosition();
|
||||
});
|
||||
this.tilesView = new TilesListView(vm.tiles, () => this.restoreScrollPosition(), this.viewClassForEntry);
|
||||
this.tilesView = new TilesListView(vm.tiles, () => this.restoreScrollPosition(), this.viewClassForTile);
|
||||
const root = t.div({className: "Timeline"}, [
|
||||
t.div({
|
||||
className: "Timeline_scroller bottom-aligned-scroll",
|
||||
|
@ -184,12 +184,12 @@ class TilesListView extends ListView<SimpleTile, TileView> {
|
|||
|
||||
private onChanged: () => void;
|
||||
|
||||
constructor(tiles: ObservableList<SimpleTile>, onChanged: () => void, private readonly viewClassForEntry: ViewClassForEntryFn) {
|
||||
constructor(tiles: ObservableList<SimpleTile>, onChanged: () => void, private readonly viewClassForTile: ViewClassForEntryFn) {
|
||||
super({
|
||||
list: tiles,
|
||||
onItemClick: (tileView, evt) => tileView.onClick(evt),
|
||||
}, entry => {
|
||||
const View = viewClassForEntry(entry);
|
||||
const View = viewClassForTile(entry);
|
||||
return new View(entry);
|
||||
});
|
||||
this.onChanged = onChanged;
|
||||
|
@ -202,7 +202,7 @@ class TilesListView extends ListView<SimpleTile, TileView> {
|
|||
|
||||
onUpdate(index: number, value: SimpleTile, param: any) {
|
||||
if (param === "shape") {
|
||||
const ExpectedClass = this.viewClassForEntry(value);
|
||||
const ExpectedClass = this.viewClassForTile(value);
|
||||
const child = this.getChildInstanceByIndex(index);
|
||||
if (!ExpectedClass || !(child instanceof ExpectedClass)) {
|
||||
// shape was updated, so we need to recreate the tile view,
|
||||
|
|
|
@ -26,7 +26,7 @@ import {SimpleTile} from "../../../../../domain/session/room/timeline/tiles/Simp
|
|||
import {GapView} from "./timeline/GapView.js";
|
||||
import type {TileViewConstructor, ViewClassForEntryFn} from "./TimelineView";
|
||||
|
||||
export function viewClassForEntry(vm: SimpleTile): TileViewConstructor {
|
||||
export function viewClassForTile(vm: SimpleTile): TileViewConstructor {
|
||||
switch (vm.shape) {
|
||||
case "gap":
|
||||
return GapView;
|
||||
|
|
|
@ -16,11 +16,11 @@ limitations under the License.
|
|||
|
||||
import {renderStaticAvatar} from "../../../avatar";
|
||||
import {TemplateView} from "../../../general/TemplateView";
|
||||
import {viewClassForEntry} from "../common";
|
||||
import {viewClassForTile} from "../common";
|
||||
|
||||
export class ReplyPreviewView extends TemplateView {
|
||||
render(t, vm) {
|
||||
const viewClass = viewClassForEntry(vm);
|
||||
const viewClass = viewClassForTile(vm);
|
||||
if (!viewClass) {
|
||||
throw new Error(`Shape ${vm.shape} is unrecognized.`)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue