From f01d5d95d988b94d1137d302445c637601c51666 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 17 Dec 2021 12:46:26 +0530 Subject: [PATCH] Reuse code from timeline view --- .../session/room/timeline/ReplyPreviewView.js | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/platform/web/ui/session/room/timeline/ReplyPreviewView.js b/src/platform/web/ui/session/room/timeline/ReplyPreviewView.js index 741200d8..b6febf28 100644 --- a/src/platform/web/ui/session/room/timeline/ReplyPreviewView.js +++ b/src/platform/web/ui/session/room/timeline/ReplyPreviewView.js @@ -17,11 +17,7 @@ limitations under the License. import {renderStaticAvatar} from "../../../avatar"; import {tag} from "../../../general/html"; import {TemplateView} from "../../../general/TemplateView"; -import {FileView} from "./FileView"; -import {ImageView} from "./ImageView"; -import {RedactedView} from "./RedactedView"; -import {TextMessageView} from "./TextMessageView.js"; -import {VideoView} from "./VideoView"; +import {viewClassForEntry} from "../TimelineView"; export class ReplyPreviewView extends TemplateView { render(t, vm) { @@ -29,7 +25,9 @@ export class ReplyPreviewView extends TemplateView { } _renderReplyPreview(t, vm) { - const view = this._viewFromViewModel(vm); + // todo: this should probably be called viewClassForTile instead + const viewClass = viewClassForEntry(vm); + const view = new viewClass(vm) const rendered = this._renderContent(t, vm, view); return this._renderReplyHeader(vm, [rendered]); } @@ -44,24 +42,6 @@ export class ReplyPreviewView extends TemplateView { } } - _viewFromViewModel(vm) { - if (vm.isRedacted) { - return new RedactedView(vm); - } - const shape = vm.shape; - switch (shape) { - case "image": - return new ImageView(vm); - case "video": - return new VideoView(vm); - case "file": - return new FileView(vm); - case "message": - case "message-status": - return new TextMessageView(vm); - } - } - _renderReplyHeader(vm, children = []) { return tag.blockquote( [