DEV: dry up the Do Not Disturb widget (#19494)

This commit is contained in:
Andrei Prigorshnev 2023-01-30 21:23:06 +04:00 committed by GitHub
parent 587e9ed9ba
commit b334f0070d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 16 deletions

View File

@ -11,21 +11,8 @@ export default createWidget("do-not-disturb", {
saving: false,
html() {
if (this.currentUser.isInDoNotDisturb()) {
return [
h("button.btn-flat.do-not-disturb-inner-container", [
iconNode("toggle-on"),
this.label(),
]),
];
} else {
return [
h("button.btn-flat.do-not-disturb-inner-container", [
iconNode("toggle-off"),
h("span.do-not-disturb-label", I18n.t("pause_notifications.label")),
]),
];
}
const isOn = this.currentUser.isInDoNotDisturb();
return [this._menuButton(isOn)];
},
click() {
@ -44,7 +31,15 @@ export default createWidget("do-not-disturb", {
}
},
label() {
_menuButton(isOn) {
const icon = iconNode(isOn ? "toggle-on" : "toggle-off");
return h("button.btn-flat.do-not-disturb-inner-container", [
icon,
this._label(),
]);
},
_label() {
const content = [h("span", I18n.t("pause_notifications.label"))];
const until = this.currentUser.do_not_disturb_until;