@@ -51,7 +51,8 @@ export default class extends Controller {
5151 }
5252
5353 this . eventSources . forEach ( ( eventSource ) => {
54- const listener = ( event : MessageEvent ) => this . _notify ( JSON . parse ( event . data ) . summary ) ;
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 ) ;
55+
5556 eventSource . addEventListener ( 'message' , listener ) ;
5657 this . listeners . set ( eventSource , listener ) ;
5758 } ) ;
@@ -72,19 +73,20 @@ export default class extends Controller {
7273 this . eventSources = [ ] ;
7374 }
7475
75- _notify ( content : string | undefined ) {
76+ _notify ( content : string | undefined , tag : string | undefined , body : string | undefined , icon : string | undefined , renotify : boolean | undefined ) {
7677 if ( ! content ) return ;
78+ if ( ! tag ) tag = '' ;
7779
7880 if ( 'granted' === Notification . permission ) {
79- new Notification ( content ) ;
81+ new Notification ( content , { tag : tag , body : body , icon : icon , renotify : renotify } ) ;
8082
8183 return ;
8284 }
8385
8486 if ( 'denied' !== Notification . permission ) {
8587 Notification . requestPermission ( ) . then ( ( permission ) => {
8688 if ( 'granted' === permission ) {
87- new Notification ( content ) ;
89+ new Notification ( content , { tag : tag , body : body , icon : icon , renotify : renotify } ) ;
8890 }
8991 } ) ;
9092 }
0 commit comments