@@ -2,11 +2,15 @@ const { remote } = require('electron');
22
33import { generateGitHubWebUrl } from '../utils/helpers' ;
44import { reOpenWindow , openExternalLink } from '../utils/comms' ;
5- import { SubjectType } from '../../types/github' ;
5+ import { Notification } from '../../types/github' ;
66import { SettingsState } from '../../types/reducers' ;
77
88export default {
9- setup ( notifications , notificationsCount , settings : SettingsState ) {
9+ setup (
10+ notifications : Notification [ ] ,
11+ notificationsCount ,
12+ settings : SettingsState
13+ ) {
1014 // If there are no new notifications just stop there
1115 if ( ! notificationsCount ) {
1216 return ;
@@ -21,11 +25,15 @@ export default {
2125 }
2226 } ,
2327
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 ;
2632
2733 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 ] ;
2937 title = `Gitify - ${ notification . repository . full_name } ` ;
3038 body = notification . subject . title ;
3139 notificationUrl = notification . subject . url ;
@@ -42,10 +50,13 @@ export default {
4250 nativeNotification . onclick = function ( ) {
4351 if ( count === 1 ) {
4452 const appWindow = remote . getCurrentWindow ( ) ;
45- const url = generateGitHubWebUrl ( notificationUrl ) ;
46-
4753 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+ }
4960 } else {
5061 reOpenWindow ( ) ;
5162 }
0 commit comments