feat(ags): allow defining notif command at instantiation
This commit is contained in:
parent
bc3e5525c3
commit
31ece1083a
3 changed files with 18 additions and 8 deletions
|
@ -51,9 +51,9 @@ const NotificationIcon = ({ appEntry, appIcon, image }) => {
|
|||
});
|
||||
};
|
||||
|
||||
export default ({ id, summary, body, actions, urgency, time, ...icon }) => Draggable({
|
||||
export default ({ id, summary, body, actions, urgency, time, command = i => {}, ...icon }) => Draggable({
|
||||
maxOffset: 200,
|
||||
command: () => Notifications.close(id),
|
||||
command: () => command(id),
|
||||
properties: [['hovered', false]],
|
||||
onHover: w => {
|
||||
if (!w._hovered) {
|
||||
|
|
|
@ -37,10 +37,13 @@ const NotificationList = () => Box({
|
|||
if (box.children.length == 0) {
|
||||
box.children = Notifications.notifications
|
||||
.reverse()
|
||||
.map(n => Notification(n));
|
||||
.map(n => Notification({ ...n, command: i => Notifications.close(i), }));
|
||||
}
|
||||
else if (id) {
|
||||
box.add(Notification(Notifications.getNotification(id)));
|
||||
box.add(Notification({
|
||||
...Notifications.getNotification(id),
|
||||
command: i => Notifications.close(i),
|
||||
}));
|
||||
box.show_all();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ const Popups = () => Box({
|
|||
box.get_parent().reveal_child = false;
|
||||
|
||||
timeout(200, () => {
|
||||
source_remove(box._map.get(id)?.interval);
|
||||
if (box._map.get(id).interval) {
|
||||
source_remove(box._map.get(id).interval);
|
||||
}
|
||||
box._map.get(id)?.destroy();
|
||||
box._map.delete(id);
|
||||
});
|
||||
|
@ -29,7 +31,12 @@ const Popups = () => Box({
|
|||
return;
|
||||
|
||||
box._map.delete(id);
|
||||
box._map.set(id, Notification(Notifications.getNotification(id)));
|
||||
|
||||
box._map.set(id, Notification({
|
||||
...Notifications.getNotification(id),
|
||||
command: i => Notifications.dismiss(i),
|
||||
}));
|
||||
|
||||
box.children = Array.from(box._map.values()).reverse();
|
||||
timeout(10, () => {
|
||||
box.get_parent().revealChild = true;
|
||||
|
@ -38,8 +45,8 @@ const Popups = () => Box({
|
|||
if (!box._map.get(id)._hovered) {
|
||||
box._map.get(id).child.setStyle(box._map.get(id).child._leftAnim);
|
||||
|
||||
if (box._map.get(id)?.interval) {
|
||||
source_remove(box._map.get(id)?.interval);
|
||||
if (box._map.get(id).interval) {
|
||||
source_remove(box._map.get(id).interval);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue