@@ -51,7 +51,14 @@ export default class extends Controller {
5151 }
5252
5353 this . eventSources . forEach ( ( eventSource ) => {
54- const listener = ( event : MessageEvent ) => this . _notify ( JSON . parse ( event . data ) . summary , JSON . parse ( event . data ) . tag , JSON . parse ( event . data ) . body , JSON . parse ( event . data ) . icon , JSON . parse ( event . data ) . renotify ) ;
54+ const listener = ( event : MessageEvent ) =>
55+ this . _notify (
56+ JSON . parse ( event . data ) . summary ,
57+ JSON . parse ( event . data ) . tag ,
58+ JSON . parse ( event . data ) . body ,
59+ JSON . parse ( event . data ) . icon ,
60+ JSON . parse ( event . data ) . renotify
61+ ) ;
5562
5663 eventSource . addEventListener ( 'message' , listener ) ;
5764 this . listeners . set ( eventSource , listener ) ;
@@ -73,20 +80,26 @@ export default class extends Controller {
7380 this . eventSources = [ ] ;
7481 }
7582
76- _notify ( content : string | undefined , tag : string | undefined , body : string | undefined , icon : string | undefined , renotify : boolean | undefined ) {
83+ _notify (
84+ content : string | undefined ,
85+ tag : string | undefined ,
86+ body : string | undefined ,
87+ icon : string | undefined ,
88+ renotify : boolean | undefined
89+ ) {
7790 if ( ! content ) return ;
7891 if ( ! tag ) tag = '' ;
7992
8093 if ( 'granted' === Notification . permission ) {
81- new Notification ( content , { tag : tag , body : body , icon : icon , renotify : renotify } ) ;
94+ new Notification ( content , { tag : tag , body : body , icon : icon , renotify : renotify } ) ;
8295
8396 return ;
8497 }
8598
8699 if ( 'denied' !== Notification . permission ) {
87100 Notification . requestPermission ( ) . then ( ( permission ) => {
88101 if ( 'granted' === permission ) {
89- new Notification ( content , { tag : tag , body : body , icon : icon , renotify : renotify } ) ;
102+ new Notification ( content , { tag : tag , body : body , icon : icon , renotify : renotify } ) ;
90103 }
91104 } ) ;
92105 }
0 commit comments