Use the proper tile view to display reply preview

This commit is contained in:
Danila Fedorin 2021-07-22 14:10:59 -07:00
parent 650389538d
commit b0c5b2f2ce
2 changed files with 16 additions and 14 deletions

View file

@ -18,6 +18,7 @@ import {TemplateView} from "../../general/TemplateView.js";
import {Popup} from "../../general/Popup.js";
import {Menu} from "../../general/Menu.js";
import {TextMessageView} from "./timeline/TextMessageView.js";
import {viewClassForEntry} from "./TimelineList.js"
export class MessageComposer extends TemplateView {
constructor(viewModel) {
@ -33,8 +34,10 @@ export class MessageComposer extends TemplateView {
onKeydown: e => this._onKeyDown(e),
onInput: () => vm.setInput(this._input.value),
});
const replyPreview = t.map(vm => vm.replyViewModel, (rvm, t) => !rvm ? null :
t.div({
const replyPreview = t.map(vm => vm.replyViewModel, (rvm, t) => {
const View = rvm && viewClassForEntry(rvm);
if (!View) { return null; }
return t.div({
className: "MessageComposer_replyPreview"
}, [
t.span({ className: "replying" }, "Replying"),
@ -42,10 +45,9 @@ export class MessageComposer extends TemplateView {
className: "cancel",
onClick: () => this._clearReplyingTo()
}, "Close"),
// TODO need proper view, not just assumed TextMessageView
t.view(new TextMessageView(vm.replyViewModel, true, "div"))
t.view(new View(rvm, true, "div"))
])
);
});
const input = t.div({className: "MessageComposer_input"}, [
this._input,
t.button({

View file

@ -24,7 +24,7 @@ import {MissingAttachmentView} from "./timeline/MissingAttachmentView.js";
import {AnnouncementView} from "./timeline/AnnouncementView.js";
import {RedactedView} from "./timeline/RedactedView.js";
function viewClassForEntry(entry) {
export function viewClassForEntry(entry) {
switch (entry.shape) {
case "gap": return GapView;
case "announcement": return AnnouncementView;