No need to handle redaction specially

This commit is contained in:
RMidhunSuresh 2021-12-16 17:52:59 +05:30
parent 13cba84445
commit 2773642406

View file

@ -19,52 +19,35 @@ import {tag} from "../../../general/html";
import {TemplateView} from "../../../general/TemplateView"; import {TemplateView} from "../../../general/TemplateView";
import {FileView} from "./FileView"; import {FileView} from "./FileView";
import {ImageView} from "./ImageView"; import {ImageView} from "./ImageView";
import {RedactedView} from "./RedactedView";
import {TextMessageView} from "./TextMessageView.js"; import {TextMessageView} from "./TextMessageView.js";
import {VideoView} from "./VideoView"; import {VideoView} from "./VideoView";
export class ReplyPreviewView extends TemplateView { export class ReplyPreviewView extends TemplateView {
render(t, vm) { render(t, vm) {
const replyContainer = t.div({ className: "ReplyPreviewView" }, [ return t.div({ className: "ReplyPreviewView" }, this._renderReplyPreview(t, vm));
vm.isRedacted
? this._renderRedaction(vm)
: this._renderReplyPreview(t, vm),
]);
return replyContainer;
}
_renderRedaction(vm) {
const children = [tag.span({ className: "statusMessage" }, vm.description), tag.br()];
const reply = this._renderReplyHeader(vm, children);
return reply;
} }
_renderReplyPreview(t, vm) { _renderReplyPreview(t, vm) {
let reply; const view = this._viewFromViewModel(vm);
const rendered = this._renderContent(t, vm, view);
return this._renderReplyHeader(vm, [rendered]);
}
_renderContent(t, vm, view) {
switch (vm.shape) { switch (vm.shape) {
case "image": case "image":
case "video": case "video":
reply = this._renderMediaPreview(t, vm); return view.renderMedia(t, vm);
break;
default: default:
reply = this._renderPreview(t, vm); return view.renderMessageBody(t, vm);
break;
} }
return reply;
} }
_renderPreview(t, vm) { _viewFromViewModel(vm) {
const view = this._viewFromShape(vm); if (vm.isRedacted) {
const rendered = view.renderMessageBody(t, vm); return new RedactedView(vm);
return this._renderReplyHeader(vm, [rendered]);
} }
_renderMediaPreview(t, vm) {
const view = this._viewFromShape(vm);
const rendered = view.renderMedia(t, vm);
return this._renderReplyHeader(vm, [rendered]);
}
_viewFromShape(vm) {
const shape = vm.shape; const shape = vm.shape;
switch (shape) { switch (shape) {
case "image": case "image":