From 94883107214b7ef8430ad888a17ce96a83d4c410 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Fri, 15 Sep 2023 12:32:30 -0400 Subject: [PATCH] fix(ags): make close button work in noti center --- config/ags/js/notifications/base.js | 5 +++- config/ags/js/notifications/center.js | 43 +++++++++++++++++---------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/config/ags/js/notifications/base.js b/config/ags/js/notifications/base.js index ed61ccb..d4f4516 100644 --- a/config/ags/js/notifications/base.js +++ b/config/ags/js/notifications/base.js @@ -54,7 +54,10 @@ const NotificationIcon = ({ appEntry, appIcon, image }) => { export default ({ id, summary, body, actions, urgency, time, command = i => {}, ...icon }) => Draggable({ maxOffset: 200, command: () => command(id), - properties: [['hovered', false]], + properties: [ + ['hovered', false], + ['id', id], + ], onHover: w => { if (!w._hovered) { w._hovered = true; diff --git a/config/ags/js/notifications/center.js b/config/ags/js/notifications/center.js index 7f9686d..a0b96e6 100644 --- a/config/ags/js/notifications/center.js +++ b/config/ags/js/notifications/center.js @@ -1,5 +1,6 @@ const { Notifications } = ags.Service; const { Button, Label, Box, Icon, Scrollable, Window, Revealer } = ags.Widget; +const { timeout } = ags.Utils; import Notification from './base.js'; import { EventBox } from '../misc/cursorbox.js' @@ -33,22 +34,34 @@ const Header = () => Box({ const NotificationList = () => Box({ vertical: true, vexpand: true, - connections: [[Notifications, (box, id) => { - if (box.children.length == 0) { - box.children = Notifications.notifications - .reverse() - .map(n => Notification({ ...n, command: i => Notifications.close(i), })); - } - else if (id) { - box.add(Notification({ - ...Notifications.getNotification(id), - command: i => Notifications.close(i), - })); - box.show_all(); - } + connections: [ + [Notifications, (box, id) => { + if (box.children.length == 0) { + box.children = Notifications.notifications + .reverse() + .map(n => Notification({ ...n, command: i => Notifications.close(i), })); + } + else if (id) { + box.add(Notification({ + ...Notifications.getNotification(id), + command: i => Notifications.close(i), + })); + box.show_all(); + } - box.visible = Notifications.notifications.length > 0; - }, 'notified']], + box.visible = Notifications.notifications.length > 0; + }, 'notified'], + + [Notifications, (box, id) => { + for (const ch of box.children) { + if (ch._id == id) { + ch.child.setStyle(ch.child._rightAnim); + timeout(500, () => box.remove(ch)); + return; + } + } + }, 'closed'], + ], }); const Placeholder = () => Revealer({