File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -25,23 +25,35 @@ var NotificationsStore = Reflux.createStore({
2525 isNewNotification : function ( response ) {
2626 var self = this ;
2727 var playSound = SettingsStore . getSettings ( ) . playSound ;
28+ var showNotification = SettingsStore . getSettings ( ) . showNotification ;
2829
29- if ( ! playSound ) { return ; }
30+ if ( ! playSound && ! showNotification ) { return ; }
3031
3132 // Check if notification is already in the store.
32- var isNew = false ;
33+ var countNew = 0 ;
3334 _ . map ( response , function ( obj ) {
3435 if ( ! _ . contains ( self . _previousNotifications , obj . id ) ) {
35- isNew = true ;
36+ countNew ++ ;
3637 }
3738 } ) ;
3839
3940 // Play Sound.
40- if ( isNew ) {
41+ if ( countNew > 0 ) {
4142 if ( playSound ) {
4243 var audio = new Audio ( 'sounds/digi.wav' ) ;
4344 audio . play ( ) ;
4445 }
46+ if ( showNotification ) {
47+ var body = ( countNew = 1 ?
48+ 'You\'ve got a new notification' :
49+ 'You\'ve got ' + countNew + 'notifications' ) ;
50+ var nativeNotification = new Notification ( 'Gitify' , {
51+ body : body
52+ } ) ;
53+ nativeNotification . onclick = function ( ) {
54+ ipc . sendChannel ( 'reopen-window' ) ;
55+ } ;
56+ }
4557 }
4658
4759 // Now Reset the previousNotifications array.
You can’t perform that action at this time.
0 commit comments