unify cancel option for various tiles in menu option

This commit is contained in:
Bruno Windels 2021-05-28 15:27:02 +02:00
parent 2b0fa22c8a
commit 43c082475b
4 changed files with 12 additions and 13 deletions

View file

@ -36,13 +36,12 @@ export class BaseMediaView extends BaseMessageView {
t.time(vm.date + " " + vm.time), t.time(vm.date + " " + vm.time),
]; ];
if (vm.isPending) { if (vm.isPending) {
const cancel = t.button({onClick: () => vm.abortSending(), className: "link"}, vm.i18n`Cancel`);
const sendStatus = t.div({ const sendStatus = t.div({
className: { className: {
sendStatus: true, sendStatus: true,
hidden: vm => !vm.sendStatus hidden: vm => !vm.sendStatus
}, },
}, [vm => vm.sendStatus, " ", cancel]); }, vm => vm.sendStatus);
const progress = t.progress({ const progress = t.progress({
min: 0, min: 0,
max: 100, max: 100,

View file

@ -59,7 +59,8 @@ export class BaseMessageView extends TemplateView {
return; return;
} }
this.root().classList.add("menuOpen"); this.root().classList.add("menuOpen");
this._menuPopup = new Popup(new Menu(options), () => this.root().classList.remove("menuOpen")); const onClose = () => this.root().classList.remove("menuOpen");
this._menuPopup = new Popup(new Menu(options), onClose);
this._menuPopup.trackInTemplateView(this); this._menuPopup.trackInTemplateView(this);
this._menuPopup.showRelativeTo(button, { this._menuPopup.showRelativeTo(button, {
horizontal: { horizontal: {
@ -78,7 +79,9 @@ export class BaseMessageView extends TemplateView {
createMenuOptions(vm) { createMenuOptions(vm) {
const options = []; const options = [];
if (vm.shape !== "redacted") { if (vm.isPending) {
options.push(Menu.option(vm.i18n`Cancel`, () => vm.abortSending()));
} else if (vm.shape !== "redacted") {
options.push(Menu.option(vm.i18n`Delete`, () => vm.redact())); options.push(Menu.option(vm.i18n`Delete`, () => vm.redact()));
} }
return options; return options;

View file

@ -18,17 +18,15 @@ import {BaseMessageView} from "./BaseMessageView.js";
export class FileView extends BaseMessageView { export class FileView extends BaseMessageView {
renderMessageBody(t, vm) { renderMessageBody(t, vm) {
const children = [];
if (vm.isPending) { if (vm.isPending) {
return t.p([ children.push(vm => vm.label);
vm => vm.label,
" ",
t.button({className: "link", onClick: () => vm.abortSending()}, vm.i18n`Cancel`),
]);
} else { } else {
return t.p({className: "Timeline_messageBody statusMessage"}, [ children.push(
t.button({className: "link", onClick: () => vm.download()}, vm => vm.label), t.button({className: "link", onClick: () => vm.download()}, vm => vm.label),
t.time(vm.date + " " + vm.time) t.time(vm.date + " " + vm.time)
]); );
} }
return t.p({className: "Timeline_messageBody statusMessage"}, children);
} }
} }

View file

@ -18,7 +18,6 @@ import {BaseMessageView} from "./BaseMessageView.js";
export class MissingAttachmentView extends BaseMessageView { export class MissingAttachmentView extends BaseMessageView {
renderMessageBody(t, vm) { renderMessageBody(t, vm) {
const remove = t.button({className: "link", onClick: () => vm.abortSending()}, vm.i18n`Remove`); return t.p({className: "Timeline_messageBody statusMessage"}, vm.label);
return t.p({className: "Timeline_messageBody statusMessage"}, [vm.label, " ", remove]);
} }
} }