Implement render flags

This commit is contained in:
RMidhunSuresh 2021-12-20 17:21:59 +05:30
parent 46b69b3873
commit dee22f7120
3 changed files with 6 additions and 5 deletions

View file

@ -56,7 +56,7 @@ export class MessageComposer extends TemplateView {
className: "cancel",
onClick: () => this._clearReplyingTo()
}, "Close"),
t.view(new View(rvm, false, "div"))
t.view(new View(rvm, { interactive: false }, "div"))
])
});
const input = t.div({className: "MessageComposer_input"}, [

View file

@ -24,12 +24,13 @@ import {Menu} from "../../../general/Menu.js";
import {ReactionsView} from "./ReactionsView.js";
export class BaseMessageView extends TemplateView {
constructor(value, interactive = true, tagName = "li") {
constructor(value, renderFlags, tagName = "li") {
super(value);
this._menuPopup = null;
this._tagName = tagName;
// TODO An enum could be nice to make code easier to read at call sites.
this._interactive = interactive;
this._interactive = renderFlags?.interactive ?? true;
this._isReplyPreview = renderFlags?.reply;
}
render(t, vm) {
@ -54,7 +55,7 @@ export class BaseMessageView extends TemplateView {
if (isContinuation && wasContinuation === false) {
li.removeChild(li.querySelector(".Timeline_messageAvatar"));
li.removeChild(li.querySelector(".Timeline_messageSender"));
} else if (!isContinuation && this._interactive) {
} else if (!isContinuation && !this._isReplyPreview) {
const avatar = tag.a({href: vm.memberPanelLink, className: "Timeline_messageAvatar"}, [renderStaticAvatar(vm, 30)]);
const sender = tag.div({className: `Timeline_messageSender usercolor${vm.avatarColorNumber}`}, vm.displayName);
li.insertBefore(avatar, li.firstChild);

View file

@ -26,7 +26,7 @@ export class ReplyPreviewView extends TemplateView {
_renderReplyPreview(t, vm) {
// todo: this should probably be called viewClassForTile instead
const viewClass = viewClassForEntry(vm);
const view = new viewClass(vm, false)
const view = new viewClass(vm, { reply: true, interactive: false });
const rendered = view.render(t, vm);
return this._renderReplyHeader(t, vm, [rendered]);
}