@@ -93,25 +93,20 @@ export class NotificationsController {
9393
9494 await NotificationsNode . instance . setNotifications ( startUp , emergency )
9595
96- // Emergency notifications can't be dismissed, but if the user minimizes the panel then
97- // we don't want to focus it each time we set the notification nodes.
98- // So we store it in dismissed once a focus has been fired for it.
99- const newEmergencies = emergency . map ( ( n ) => n . id ) . filter ( ( id ) => ! dismissed . has ( id ) )
100- if ( newEmergencies . length > 0 ) {
101- this . state . dismissed = [ ...this . state . dismissed , ...newEmergencies ]
102- await this . writeState ( )
103- void this . notificationsNode . focusPanel ( )
104- }
105-
10696 // Process on-receive behavior for newly received notifications that passes rule engine
107- const newlyReceivedToDisplay = [ ...startUp , ...emergency ] . filter ( ( n ) => this . state . newlyReceived . includes ( n . id ) )
108- if ( newlyReceivedToDisplay . length > 0 ) {
109- await this . notificationsNode . onReceiveNotifications ( newlyReceivedToDisplay )
97+ const wasNewlyReceived = ( n : ToolkitNotification ) => this . state . newlyReceived . includes ( n . id )
98+ const newStartUp = startUp . filter ( wasNewlyReceived )
99+ const newEmergency = emergency . filter ( wasNewlyReceived )
100+ const newlyReceived = [ ...newStartUp , ...newEmergency ]
101+
102+ if ( newlyReceived . length > 0 ) {
103+ await this . notificationsNode . onReceiveNotifications ( newlyReceived )
110104 // remove displayed notifications from newlyReceived
111- this . state . newlyReceived = this . state . newlyReceived . filter (
112- ( id ) => ! newlyReceivedToDisplay . some ( ( n ) => n . id === id )
113- )
105+ this . state . newlyReceived = this . state . newlyReceived . filter ( ( id ) => ! newlyReceived . some ( ( n ) => n . id === id ) )
114106 await this . writeState ( )
107+ if ( newEmergency . length > 0 ) {
108+ void this . notificationsNode . focusPanel ( )
109+ }
115110 }
116111 }
117112
@@ -201,7 +196,7 @@ export class NotificationsController {
201196 */
202197 private readState ( ) {
203198 const state = this . getDefaultState ( )
204- this . state . dismissed = state . dismissed
199+ this . state . dismissed = [ ... new Set ( [ ... this . state . dismissed , ... state . dismissed ] ) ]
205200 }
206201
207202 /**
0 commit comments