From 41a8e44ffdc0503382e77a9db973a6de27749173 Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Mon, 28 Oct 2024 13:16:44 +0545 Subject: [PATCH] feat: close notification on right click (#386) Co-authored-by: Jas Singh --- modules/notifications/index.ts | 35 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/notifications/index.ts b/modules/notifications/index.ts index 7e86589..9731210 100644 --- a/modules/notifications/index.ts +++ b/modules/notifications/index.ts @@ -55,21 +55,26 @@ export default (): Window, unknown> => { const filteredNotifications = filterNotifications(notifications, ignoredNotifs); return (self.children = filteredNotifications.slice(0, displayedTotal.value).map((notif) => { - return Widget.Box({ - class_name: 'notification-card', - vpack: 'start', - hexpand: true, - children: [ - Image(notif), - Widget.Box({ - vpack: 'start', - vertical: true, - hexpand: true, - class_name: `notification-card-content ${!notifHasImg(notif) ? 'noimg' : ''}`, - children: [Header(notif), Body(notif), Action(notif, notifs)], - }), - CloseButton(notif, notifs), - ], + return Widget.EventBox({ + on_secondary_click: () => { + notifs.CloseNotification(notif.id); + }, + child: Widget.Box({ + class_name: 'notification-card', + vpack: 'start', + hexpand: true, + children: [ + Image(notif), + Widget.Box({ + vpack: 'start', + vertical: true, + hexpand: true, + class_name: `notification-card-content ${!notifHasImg(notif) ? 'noimg' : ''}`, + children: [Header(notif), Body(notif), Action(notif, notifs)], + }), + CloseButton(notif, notifs), + ], + }), }); })); },