File tree Expand file tree Collapse file tree 4 files changed +23
-11
lines changed Expand file tree Collapse file tree 4 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 11# CHANGELOG
22
3+ ## 2.24.0
4+
5+ - Added ` options ` to Notification
6+
37## 2.13.2
48
59- Revert "Change JavaScript package to ` type: module ` "
Original file line number Diff line number Diff line change @@ -13,6 +13,6 @@ export default class extends Controller {
1313 initialize ( ) : void ;
1414 connect ( ) : void ;
1515 disconnect ( ) : void ;
16- _notify ( content : string | undefined ) : void ;
16+ _notify ( title : string | undefined , options : NotificationOptions | undefined ) : void ;
1717 private dispatchEvent ;
1818}
Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ class default_1 extends Controller {
2626 return ;
2727 }
2828 this . eventSources . forEach ( ( eventSource ) => {
29- const listener = ( event ) => this . _notify ( JSON . parse ( event . data ) . summary ) ;
29+ const listener = ( event ) => {
30+ const { summary, content } = JSON . parse ( event . data ) ;
31+ this . _notify ( summary , content ) ;
32+ } ;
3033 eventSource . addEventListener ( 'message' , listener ) ;
3134 this . listeners . set ( eventSource , listener ) ;
3235 } ) ;
@@ -42,17 +45,17 @@ class default_1 extends Controller {
4245 } ) ;
4346 this . eventSources = [ ] ;
4447 }
45- _notify ( content ) {
46- if ( ! content )
48+ _notify ( title , options ) {
49+ if ( ! title )
4750 return ;
4851 if ( 'granted' === Notification . permission ) {
49- new Notification ( content ) ;
52+ new Notification ( title , options ) ;
5053 return ;
5154 }
5255 if ( 'denied' !== Notification . permission ) {
5356 Notification . requestPermission ( ) . then ( ( permission ) => {
5457 if ( 'granted' === permission ) {
55- new Notification ( content ) ;
58+ new Notification ( title , options ) ;
5659 }
5760 } ) ;
5861 }
Original file line number Diff line number Diff line change @@ -49,7 +49,12 @@ export default class extends Controller {
4949 }
5050
5151 this . eventSources . forEach ( ( eventSource ) => {
52- const listener = ( event : MessageEvent ) => this . _notify ( JSON . parse ( event . data ) . summary ) ;
52+ const listener = ( event : MessageEvent ) => {
53+ const { summary, content } = JSON . parse ( event . data ) ;
54+
55+ this . _notify ( summary , content ) ;
56+ } ;
57+
5358 eventSource . addEventListener ( 'message' , listener ) ;
5459 this . listeners . set ( eventSource , listener ) ;
5560 } ) ;
@@ -70,19 +75,19 @@ export default class extends Controller {
7075 this . eventSources = [ ] ;
7176 }
7277
73- _notify ( content : string | undefined ) {
74- if ( ! content ) return ;
78+ _notify ( title : string | undefined , options : NotificationOptions | undefined ) {
79+ if ( ! title ) return ;
7580
7681 if ( 'granted' === Notification . permission ) {
77- new Notification ( content ) ;
82+ new Notification ( title , options ) ;
7883
7984 return ;
8085 }
8186
8287 if ( 'denied' !== Notification . permission ) {
8388 Notification . requestPermission ( ) . then ( ( permission ) => {
8489 if ( 'granted' === permission ) {
85- new Notification ( content ) ;
90+ new Notification ( title , options ) ;
8691 }
8792 } ) ;
8893 }
You can’t perform that action at this time.
0 commit comments