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,19 +34,20 @@ 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({
className: "MessageComposer_replyPreview"
}, [
t.span({ className: "replying" }, "Replying"),
t.button({
className: "cancel",
onClick: () => this._clearReplyingTo()
}, "Close"),
// TODO need proper view, not just assumed TextMessageView
t.view(new TextMessageView(vm.replyViewModel, true, "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"),
t.button({
className: "cancel",
onClick: () => this._clearReplyingTo()
}, "Close"),
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;