@@ -2,11 +2,15 @@ const { remote } = require('electron');
2
2
3
3
import { generateGitHubWebUrl } from '../utils/helpers' ;
4
4
import { reOpenWindow , openExternalLink } from '../utils/comms' ;
5
- import { SubjectType } from '../../types/github' ;
5
+ import { Notification } from '../../types/github' ;
6
6
import { SettingsState } from '../../types/reducers' ;
7
7
8
8
export default {
9
- setup ( notifications , notificationsCount , settings : SettingsState ) {
9
+ setup (
10
+ notifications : Notification [ ] ,
11
+ notificationsCount ,
12
+ settings : SettingsState
13
+ ) {
10
14
// If there are no new notifications just stop there
11
15
if ( ! notificationsCount ) {
12
16
return ;
@@ -21,11 +25,15 @@ export default {
21
25
}
22
26
} ,
23
27
24
- raiseNativeNotification ( notifications , count ) {
25
- let title , body , icon , notificationUrl ;
28
+ raiseNativeNotification ( notifications , count : number ) {
29
+ let title : string ;
30
+ let body : string ;
31
+ let notificationUrl : string | null ;
26
32
27
33
if ( count === 1 ) {
28
- const notification = notifications . find ( ( obj ) => obj . length > 0 ) [ 0 ] ;
34
+ const notification : Notification = notifications . find (
35
+ ( obj ) => obj . length > 0
36
+ ) [ 0 ] ;
29
37
title = `Gitify - ${ notification . repository . full_name } ` ;
30
38
body = notification . subject . title ;
31
39
notificationUrl = notification . subject . url ;
@@ -42,10 +50,13 @@ export default {
42
50
nativeNotification . onclick = function ( ) {
43
51
if ( count === 1 ) {
44
52
const appWindow = remote . getCurrentWindow ( ) ;
45
- const url = generateGitHubWebUrl ( notificationUrl ) ;
46
-
47
53
appWindow . hide ( ) ;
48
- openExternalLink ( url ) ;
54
+
55
+ // Some Notification types from GitHub are missing urls in their subjects.
56
+ if ( notificationUrl ) {
57
+ const url = generateGitHubWebUrl ( notificationUrl ) ;
58
+ openExternalLink ( url ) ;
59
+ }
49
60
} else {
50
61
reOpenWindow ( ) ;
51
62
}
0 commit comments