File tree 4 files changed +23
-11
lines changed
4 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 1
1
# CHANGELOG
2
2
3
+ ## 2.24.0
4
+
5
+ - Added ` options ` to Notification
6
+
3
7
## 2.13.2
4
8
5
9
- 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 {
13
13
initialize ( ) : void ;
14
14
connect ( ) : void ;
15
15
disconnect ( ) : void ;
16
- _notify ( content : string | undefined ) : void ;
16
+ _notify ( title : string | undefined , options : NotificationOptions | undefined ) : void ;
17
17
private dispatchEvent ;
18
18
}
Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ class default_1 extends Controller {
26
26
return ;
27
27
}
28
28
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
+ } ;
30
33
eventSource . addEventListener ( 'message' , listener ) ;
31
34
this . listeners . set ( eventSource , listener ) ;
32
35
} ) ;
@@ -42,17 +45,17 @@ class default_1 extends Controller {
42
45
} ) ;
43
46
this . eventSources = [ ] ;
44
47
}
45
- _notify ( content ) {
46
- if ( ! content )
48
+ _notify ( title , options ) {
49
+ if ( ! title )
47
50
return ;
48
51
if ( 'granted' === Notification . permission ) {
49
- new Notification ( content ) ;
52
+ new Notification ( title , options ) ;
50
53
return ;
51
54
}
52
55
if ( 'denied' !== Notification . permission ) {
53
56
Notification . requestPermission ( ) . then ( ( permission ) => {
54
57
if ( 'granted' === permission ) {
55
- new Notification ( content ) ;
58
+ new Notification ( title , options ) ;
56
59
}
57
60
} ) ;
58
61
}
Original file line number Diff line number Diff line change @@ -49,7 +49,12 @@ export default class extends Controller {
49
49
}
50
50
51
51
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
+
53
58
eventSource . addEventListener ( 'message' , listener ) ;
54
59
this . listeners . set ( eventSource , listener ) ;
55
60
} ) ;
@@ -70,19 +75,19 @@ export default class extends Controller {
70
75
this . eventSources = [ ] ;
71
76
}
72
77
73
- _notify ( content : string | undefined ) {
74
- if ( ! content ) return ;
78
+ _notify ( title : string | undefined , options : NotificationOptions | undefined ) {
79
+ if ( ! title ) return ;
75
80
76
81
if ( 'granted' === Notification . permission ) {
77
- new Notification ( content ) ;
82
+ new Notification ( title , options ) ;
78
83
79
84
return ;
80
85
}
81
86
82
87
if ( 'denied' !== Notification . permission ) {
83
88
Notification . requestPermission ( ) . then ( ( permission ) => {
84
89
if ( 'granted' === permission ) {
85
- new Notification ( content ) ;
90
+ new Notification ( title , options ) ;
86
91
}
87
92
} ) ;
88
93
}
You can’t perform that action at this time.
0 commit comments