@@ -7,9 +7,9 @@ const appMenuTemplate = require('./electron/app-menu-template');
7
7
const iconIdle = path . join ( __dirname , 'images' , 'tray-idleTemplate.png' ) ;
8
8
const iconActive = path . join ( __dirname , 'images' , 'tray-active.png' ) ;
9
9
10
- const isDarwin = ( process . platform === 'darwin' ) ;
11
- const isLinux = ( process . platform === 'linux' ) ;
12
- const isWindows = ( process . platform === 'win32' ) ;
10
+ const isDarwin = process . platform === 'darwin' ;
11
+ const isLinux = process . platform === 'linux' ;
12
+ const isWindows = process . platform === 'win32' ;
13
13
14
14
let appWindow ;
15
15
let appIcon = null ;
@@ -18,7 +18,7 @@ let isQuitting = false;
18
18
const autoStart = new AutoLaunch ( {
19
19
name : 'Gitify' ,
20
20
path : process . execPath . match ( / .* ?\. a p p / ) [ 0 ] ,
21
- isHidden : true
21
+ isHidden : true ,
22
22
} ) ;
23
23
24
24
app . on ( 'ready' , function ( ) {
@@ -28,16 +28,18 @@ app.on('ready', function() {
28
28
const trayMenu = Menu . buildFromTemplate ( [
29
29
{
30
30
label : 'Show Gitify' ,
31
- click ( ) { appWindow . show ( ) ; }
31
+ click ( ) {
32
+ appWindow . show ( ) ;
33
+ } ,
32
34
} ,
33
35
{
34
- type : 'separator'
36
+ type : 'separator' ,
35
37
} ,
36
38
{
37
39
label : 'Quit' ,
38
40
accelerator : isDarwin ? 'Command+Q' : 'Alt+F4' ,
39
- role : 'quit'
40
- }
41
+ role : 'quit' ,
42
+ } ,
41
43
] ) ;
42
44
43
45
trayIcon . setToolTip ( 'GitHub Notifications on your menu bar.' ) ;
@@ -46,37 +48,45 @@ app.on('ready', function() {
46
48
}
47
49
48
50
function confirmAutoUpdate ( updater ) {
49
- dialog . showMessageBox ( {
50
- type : 'question' ,
51
- buttons : [ 'Update & Restart' , 'Cancel' ] ,
52
- title : 'Update Available' ,
53
- cancelId : 99 ,
54
- message : 'There is an update available. Would you like to update Gitify now?'
55
- } , function ( response ) {
56
- console . log ( 'Exit: ' + response ) ;
57
- if ( response === 0 ) {
58
- updater . install ( ) ;
51
+ dialog . showMessageBox (
52
+ {
53
+ type : 'question' ,
54
+ buttons : [ 'Update & Restart' , 'Cancel' ] ,
55
+ title : 'Update Available' ,
56
+ cancelId : 99 ,
57
+ message :
58
+ 'There is an update available. Would you like to update Gitify now?' ,
59
+ } ,
60
+ response => {
61
+ console . log ( 'Exit: ' + response ) ; // eslint-disable-line no-console
62
+
63
+ if ( response === 0 ) {
64
+ updater . install ( ) ;
65
+ }
59
66
}
60
- } ) ;
67
+ ) ;
61
68
}
62
69
63
70
function checkAutoUpdate ( showAlert ) {
64
-
65
- if ( isWindows || isLinux ) { return ; }
71
+ if ( isWindows || isLinux ) {
72
+ return ;
73
+ }
66
74
67
75
let autoUpdateOptions = {
68
76
repo : 'manosim/gitify' ,
69
- currentVersion : app . getVersion ( )
77
+ currentVersion : app . getVersion ( ) ,
70
78
} ;
71
79
72
80
const updater = new GhReleases ( autoUpdateOptions ) ;
73
81
74
82
updater . on ( 'error' , ( event , message ) => {
83
+ /* eslint-disable no-console */
75
84
console . log ( 'ERRORED.' ) ;
76
85
console . log ( 'Event: ' + JSON . stringify ( event ) + '. MESSAGE: ' + message ) ;
86
+ /* eslint-enable no-console */
77
87
} ) ;
78
88
79
- updater . on ( 'update-downloaded' , ( info ) => {
89
+ updater . on ( 'update-downloaded' , ( ) => {
80
90
// Restart the app(ask) and install the update
81
91
confirmAutoUpdate ( updater ) ;
82
92
} ) ;
@@ -89,7 +99,7 @@ app.on('ready', function() {
89
99
type : 'info' ,
90
100
buttons : [ 'Close' ] ,
91
101
title : 'No update available' ,
92
- message : 'You are currently running the latest version of Gitify.'
102
+ message : 'You are currently running the latest version of Gitify.' ,
93
103
} ) ;
94
104
}
95
105
}
@@ -100,8 +110,8 @@ app.on('ready', function() {
100
110
} ) ;
101
111
}
102
112
103
- function initWindow ( ) {
104
- var defaults = {
113
+ function initWindow ( ) {
114
+ let defaults = {
105
115
width : 500 ,
106
116
height : 600 ,
107
117
minHeight : 300 ,
@@ -111,15 +121,15 @@ app.on('ready', function() {
111
121
fullscreenable : false ,
112
122
titleBarStyle : 'hidden-inset' ,
113
123
webPreferences : {
114
- overlayScrollbars : true
115
- }
124
+ overlayScrollbars : true ,
125
+ } ,
116
126
} ;
117
127
118
128
appWindow = new BrowserWindow ( defaults ) ;
119
129
appWindow . loadURL ( 'file://' + __dirname + '/index.html' ) ;
120
130
appWindow . show ( ) ;
121
131
122
- appWindow . on ( 'close' , function ( event ) {
132
+ appWindow . on ( 'close' , function ( event ) {
123
133
if ( ! isQuitting ) {
124
134
event . preventDefault ( ) ;
125
135
appWindow . hide ( ) ;
@@ -134,12 +144,12 @@ app.on('ready', function() {
134
144
appIcon = createAppIcon ( ) ;
135
145
initWindow ( ) ;
136
146
137
- ipcMain . on ( 'reopen-window' , ( ) => appWindow . show ( ) ) ;
138
- ipcMain . on ( 'startup-enable' , ( ) => autoStart . enable ( ) ) ;
139
- ipcMain . on ( 'startup-disable' , ( ) => autoStart . disable ( ) ) ;
140
- ipcMain . on ( 'check-update' , ( ) => checkAutoUpdate ( true ) ) ;
147
+ ipcMain . on ( 'reopen-window' , ( ) => appWindow . show ( ) ) ;
148
+ ipcMain . on ( 'startup-enable' , ( ) => autoStart . enable ( ) ) ;
149
+ ipcMain . on ( 'startup-disable' , ( ) => autoStart . disable ( ) ) ;
150
+ ipcMain . on ( 'check-update' , ( ) => checkAutoUpdate ( true ) ) ;
141
151
ipcMain . on ( 'set-badge' , ( event , count ) => app . setBadgeCount ( count ) ) ;
142
- ipcMain . on ( 'app-quit' , ( ) => app . quit ( ) ) ;
152
+ ipcMain . on ( 'app-quit' , ( ) => app . quit ( ) ) ;
143
153
144
154
ipcMain . on ( 'update-icon' , ( event , arg ) => {
145
155
if ( ! appIcon . isDestroyed ( ) ) {
@@ -177,14 +187,14 @@ app.on('ready', function() {
177
187
} ) ;
178
188
} ) ;
179
189
180
- app . on ( 'activate' , ( ) => appWindow . show ( ) ) ;
190
+ app . on ( 'activate' , ( ) => appWindow . show ( ) ) ;
181
191
182
192
app . on ( 'window-all-closed' , ( ) => {
183
193
if ( ! isDarwin ) {
184
194
app . quit ( ) ;
185
195
}
186
196
} ) ;
187
197
188
- app . on ( 'before-quit' , ( event ) => {
198
+ app . on ( 'before-quit' , ( ) => {
189
199
isQuitting = true ;
190
200
} ) ;
0 commit comments