[Notifications] Add toggle

This commit is contained in:
Janis Hutz 2025-03-23 14:10:54 +01:00
parent 7ff986e7a6
commit d387d02534
2 changed files with 16 additions and 1 deletions

View File

@ -22,6 +22,9 @@ App.start({
} else if ( request == 'clear-newest' ) { } else if ( request == 'clear-newest' ) {
not.clearNewestNotifications( 0 ); not.clearNewestNotifications( 0 );
res( 'Cleared newest notification' ); res( 'Cleared newest notification' );
} else if ( request == 'toggle' ) {
not.toggleNotificationMenu( 0 );
res( 'Toggled notifications' );
} else { } else {
res( 'Unknown command!' ); res( 'Unknown command!' );
} }

View File

@ -39,7 +39,7 @@ class Notifier implements Subscribable {
} ); } );
this.notifd.connect( 'resolved', ( _, id ) => { 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 () { clearAllNotifications () {
this.menuOpen = false; this.menuOpen = false;
this.notifications.forEach( ( _, id ) => { this.notifications.forEach( ( _, id ) => {
@ -157,6 +165,10 @@ const closeNotificationMenu = ( id: number ) => {
notifiers.get( id )?.hideNotifications(); notifiers.get( id )?.hideNotifications();
} }
const toggleNotificationMenu = ( id: number ) => {
notifiers.get( id )?.toggleNotificationMenu();
}
const clearAllNotifications = ( id: number ) => { const clearAllNotifications = ( id: number ) => {
notifiers.get( id )?.clearAllNotifications(); notifiers.get( id )?.clearAllNotifications();
} }