unify cancel option for various tiles in menu option
This commit is contained in:
parent
2b0fa22c8a
commit
43c082475b
4 changed files with 12 additions and 13 deletions
|
@ -36,13 +36,12 @@ export class BaseMediaView extends BaseMessageView {
|
|||
t.time(vm.date + " " + vm.time),
|
||||
];
|
||||
if (vm.isPending) {
|
||||
const cancel = t.button({onClick: () => vm.abortSending(), className: "link"}, vm.i18n`Cancel`);
|
||||
const sendStatus = t.div({
|
||||
className: {
|
||||
sendStatus: true,
|
||||
hidden: vm => !vm.sendStatus
|
||||
},
|
||||
}, [vm => vm.sendStatus, " ", cancel]);
|
||||
}, vm => vm.sendStatus);
|
||||
const progress = t.progress({
|
||||
min: 0,
|
||||
max: 100,
|
||||
|
|
|
@ -59,7 +59,8 @@ export class BaseMessageView extends TemplateView {
|
|||
return;
|
||||
}
|
||||
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.showRelativeTo(button, {
|
||||
horizontal: {
|
||||
|
@ -78,7 +79,9 @@ export class BaseMessageView extends TemplateView {
|
|||
|
||||
createMenuOptions(vm) {
|
||||
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()));
|
||||
}
|
||||
return options;
|
||||
|
|
|
@ -18,17 +18,15 @@ import {BaseMessageView} from "./BaseMessageView.js";
|
|||
|
||||
export class FileView extends BaseMessageView {
|
||||
renderMessageBody(t, vm) {
|
||||
const children = [];
|
||||
if (vm.isPending) {
|
||||
return t.p([
|
||||
vm => vm.label,
|
||||
" ",
|
||||
t.button({className: "link", onClick: () => vm.abortSending()}, vm.i18n`Cancel`),
|
||||
]);
|
||||
children.push(vm => vm.label);
|
||||
} else {
|
||||
return t.p({className: "Timeline_messageBody statusMessage"}, [
|
||||
children.push(
|
||||
t.button({className: "link", onClick: () => vm.download()}, vm => vm.label),
|
||||
t.time(vm.date + " " + vm.time)
|
||||
]);
|
||||
);
|
||||
}
|
||||
return t.p({className: "Timeline_messageBody statusMessage"}, children);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import {BaseMessageView} from "./BaseMessageView.js";
|
|||
|
||||
export class MissingAttachmentView extends BaseMessageView {
|
||||
renderMessageBody(t, vm) {
|
||||
const remove = t.button({className: "link", onClick: () => vm.abortSending()}, vm.i18n`Remove`);
|
||||
return t.p({className: "Timeline_messageBody statusMessage"}, [vm.label, " ", remove]);
|
||||
return t.p({className: "Timeline_messageBody statusMessage"}, vm.label);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue