From d387d02534b3a3d9650ce7468165d0f589322365 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Sun, 23 Mar 2025 14:10:54 +0100 Subject: [PATCH] [Notifications] Add toggle --- config/ags/notifications/app.ts | 3 +++ config/ags/notifications/handler.tsx | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config/ags/notifications/app.ts b/config/ags/notifications/app.ts index 548b260..54db34f 100644 --- a/config/ags/notifications/app.ts +++ b/config/ags/notifications/app.ts @@ -22,6 +22,9 @@ App.start({ } else if ( request == 'clear-newest' ) { not.clearNewestNotifications( 0 ); res( 'Cleared newest notification' ); + } else if ( request == 'toggle' ) { + not.toggleNotificationMenu( 0 ); + res( 'Toggled notifications' ); } else { res( 'Unknown command!' ); } diff --git a/config/ags/notifications/handler.tsx b/config/ags/notifications/handler.tsx index 44f34a8..8e8b224 100644 --- a/config/ags/notifications/handler.tsx +++ b/config/ags/notifications/handler.tsx @@ -39,7 +39,7 @@ class Notifier implements Subscribable { } ); this.notifd.connect( 'resolved', ( _, id ) => { - this.hide( id ); + this.delete( id ); } ); } @@ -124,6 +124,14 @@ class Notifier implements Subscribable { } ) } + toggleNotificationMenu () { + if ( this.menuOpen ) { + this.hideNotifications(); + } else { + this.openNotificationMenu(); + } + } + clearAllNotifications () { this.menuOpen = false; this.notifications.forEach( ( _, id ) => { @@ -157,6 +165,10 @@ const closeNotificationMenu = ( id: number ) => { notifiers.get( id )?.hideNotifications(); } +const toggleNotificationMenu = ( id: number ) => { + notifiers.get( id )?.toggleNotificationMenu(); +} + const clearAllNotifications = ( id: number ) => { notifiers.get( id )?.clearAllNotifications(); }