@@ -165,33 +165,26 @@ app.whenReady().then(async () => {
165
165
EVENTS . USE_UNREAD_ACTIVE_ICON ,
166
166
( _ , useUnreadActiveIcon : boolean ) => {
167
167
shouldUseUnreadActiveIcon = useUnreadActiveIcon ;
168
-
169
- if ( shouldUseUnreadActiveIcon ) {
170
- setActiveIcon ( ) ;
171
- } else {
172
- setIdleIcon ( ) ;
173
- }
174
168
} ,
175
169
) ;
176
170
177
- onMainEvent ( EVENTS . ICON_ERROR , ( ) => {
171
+ onMainEvent ( EVENTS . UPDATE_ICON_COLOR , ( _ , notificationsCount : number ) => {
178
172
if ( ! mb . tray . isDestroyed ( ) ) {
179
- mb . tray . setImage ( TrayIcons . error ) ;
180
- }
181
- } ) ;
173
+ if ( notificationsCount < 0 ) {
174
+ setErrorIcon ( ) ;
175
+ return ;
176
+ }
182
177
183
- onMainEvent ( EVENTS . ICON_ACTIVE , ( ) => {
184
- if ( ! mb . tray . isDestroyed ( ) && shouldUseUnreadActiveIcon ) {
185
- }
186
- } ) ;
178
+ if ( notificationsCount > 0 ) {
179
+ setActiveIcon ( ) ;
180
+ return ;
181
+ }
187
182
188
- onMainEvent ( EVENTS . ICON_IDLE , ( ) => {
189
- if ( ! mb . tray . isDestroyed ( ) ) {
190
183
setIdleIcon ( ) ;
191
184
}
192
185
} ) ;
193
186
194
- onMainEvent ( EVENTS . UPDATE_TITLE , ( _ , title : string ) => {
187
+ onMainEvent ( EVENTS . UPDATE_ICON_TITLE , ( _ , title : string ) => {
195
188
if ( ! mb . tray . isDestroyed ( ) ) {
196
189
mb . tray . setTitle ( title ) ;
197
190
}
@@ -256,14 +249,6 @@ const handleURL = (url: string) => {
256
249
}
257
250
} ;
258
251
259
- function setActiveIcon ( ) {
260
- mb . tray . setImage (
261
- menuBuilder . isUpdateAvailable ( )
262
- ? TrayIcons . activeWithUpdate
263
- : TrayIcons . active ,
264
- ) ;
265
- }
266
-
267
252
function setIdleIcon ( ) {
268
253
if ( shouldUseAlternateIdleIcon ) {
269
254
mb . tray . setImage (
@@ -279,3 +264,19 @@ function setIdleIcon() {
279
264
) ;
280
265
}
281
266
}
267
+
268
+ function setActiveIcon ( ) {
269
+ if ( shouldUseUnreadActiveIcon ) {
270
+ mb . tray . setImage (
271
+ menuBuilder . isUpdateAvailable ( )
272
+ ? TrayIcons . activeWithUpdate
273
+ : TrayIcons . active ,
274
+ ) ;
275
+ } else {
276
+ setIdleIcon ( ) ;
277
+ }
278
+ }
279
+
280
+ function setErrorIcon ( ) {
281
+ mb . tray . setImage ( TrayIcons . error ) ;
282
+ }
0 commit comments