forked from Shinonome/dots-hyprland
notifs: fix Clear and Silence button
This commit is contained in:
@@ -13,17 +13,6 @@ import { ConfigToggle, ConfigSegmentedSelection, ConfigGap } from '../../lib/con
|
|||||||
import Notification from "../../lib/notification.js";
|
import Notification from "../../lib/notification.js";
|
||||||
|
|
||||||
export default (props) => {
|
export default (props) => {
|
||||||
const dndToggle = ConfigToggle({
|
|
||||||
hpack: 'center',
|
|
||||||
icon: 'notifications_paused',
|
|
||||||
name: 'Do not disturb',
|
|
||||||
desc: "Don't pop up notifications",
|
|
||||||
initValue: Notifications.dnd,
|
|
||||||
onChange: (self, newValue) => {
|
|
||||||
Notifications.dnd = newValue;
|
|
||||||
silenceButton.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const notifEmptyContent = Box({
|
const notifEmptyContent = Box({
|
||||||
homogeneous: true,
|
homogeneous: true,
|
||||||
children: [Box({
|
children: [Box({
|
||||||
@@ -39,7 +28,6 @@ export default (props) => {
|
|||||||
Label({ label: 'No notifications', className: 'txt-small' }),
|
Label({ label: 'No notifications', className: 'txt-small' }),
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
dndToggle,
|
|
||||||
]
|
]
|
||||||
})]
|
})]
|
||||||
});
|
});
|
||||||
@@ -99,29 +87,25 @@ export default (props) => {
|
|||||||
});
|
});
|
||||||
const silenceButton = ListActionButton('notifications_paused', 'Silence', (self) => {
|
const silenceButton = ListActionButton('notifications_paused', 'Silence', (self) => {
|
||||||
Notifications.dnd = !Notifications.dnd;
|
Notifications.dnd = !Notifications.dnd;
|
||||||
dndToggle._toggle(Notifications.dnd)
|
|
||||||
self.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
|
self.toggleClassName('notif-listaction-btn-enabled', Notifications.dnd);
|
||||||
});
|
});
|
||||||
const clearButton = ListActionButton('clear_all', 'Clear', () => Notifications.clear());
|
const clearButton = ListActionButton('clear_all', 'Clear', () => {
|
||||||
const listTitle = Revealer({
|
notificationList.get_children().forEach(ch => ch.destroy());
|
||||||
revealChild: false,
|
Notifications.clear();
|
||||||
connections: [[Notifications, (revealer) => {
|
});
|
||||||
revealer.revealChild = (Notifications.notifications.length > 0);
|
const listTitle = Box({
|
||||||
}]],
|
vpack: 'start',
|
||||||
child: Box({
|
className: 'sidebar-group-invisible txt spacing-h-5',
|
||||||
vpack: 'start',
|
children: [
|
||||||
className: 'sidebar-group-invisible txt spacing-h-5',
|
Label({
|
||||||
children: [
|
hexpand: true,
|
||||||
Label({
|
xalign: 0,
|
||||||
hexpand: true,
|
className: 'txt-title-small',
|
||||||
xalign: 0,
|
label: 'Notifications',
|
||||||
className: 'txt-title-small',
|
}),
|
||||||
label: 'Notifications',
|
silenceButton,
|
||||||
}),
|
clearButton,
|
||||||
silenceButton,
|
]
|
||||||
clearButton,
|
|
||||||
]
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const notifList = Scrollable({
|
const notifList = Scrollable({
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
@@ -150,7 +134,7 @@ export default (props) => {
|
|||||||
});
|
});
|
||||||
return Box({
|
return Box({
|
||||||
...props,
|
...props,
|
||||||
className: 'sidebar-group-invisible spacing-v-5',
|
className: 'sidebar-group spacing-v-5',
|
||||||
vertical: true,
|
vertical: true,
|
||||||
children: [
|
children: [
|
||||||
listTitle,
|
listTitle,
|
||||||
|
|||||||
Reference in New Issue
Block a user