@@ -165,33 +165,26 @@ app.whenReady().then(async () => {
165165 EVENTS . USE_UNREAD_ACTIVE_ICON ,
166166 ( _ , useUnreadActiveIcon : boolean ) => {
167167 shouldUseUnreadActiveIcon = useUnreadActiveIcon ;
168- 169- if ( shouldUseUnreadActiveIcon ) {
170- setActiveIcon ( ) ;
171- } else {
172- setIdleIcon ( ) ;
173- }
174168 } ,
175169 ) ;
176170
177- onMainEvent ( EVENTS . ICON_ERROR , ( ) => {
171+ onMainEvent ( EVENTS . UPDATE_ICON_COLOR , ( _ , notificationsCount : number ) => {
178172 if ( ! mb . tray . isDestroyed ( ) ) {
179- mb . tray . setImage ( TrayIcons . error ) ;
180- }
181- } ) ;
173+ if ( notificationsCount < 0 ) {
174+ setErrorIcon ( ) ;
175+ return ;
176+ }
182177
183- onMainEvent ( EVENTS . ICON_ACTIVE , ( ) => {
184- if ( ! mb . tray . isDestroyed ( ) && shouldUseUnreadActiveIcon ) {
185- }
186- } ) ;
178+ if ( notificationsCount > 0 ) {
179+ setActiveIcon ( ) ;
180+ return ;
181+ }
187182
188- onMainEvent ( EVENTS . ICON_IDLE , ( ) => {
189- if ( ! mb . tray . isDestroyed ( ) ) {
190183 setIdleIcon ( ) ;
191184 }
192185 } ) ;
193186
194- onMainEvent ( EVENTS . UPDATE_TITLE , ( _ , title : string ) => {
187+ onMainEvent ( EVENTS . UPDATE_ICON_TITLE , ( _ , title : string ) => {
195188 if ( ! mb . tray . isDestroyed ( ) ) {
196189 mb . tray . setTitle ( title ) ;
197190 }
@@ -256,14 +249,6 @@ const handleURL = (url: string) => {
256249 }
257250} ;
258251
259- function setActiveIcon ( ) {
260- mb . tray . setImage (
261- menuBuilder . isUpdateAvailable ( )
262- ? TrayIcons . activeWithUpdate
263- : TrayIcons . active ,
264- ) ;
265- }
266- 267252function setIdleIcon ( ) {
268253 if ( shouldUseAlternateIdleIcon ) {
269254 mb . tray . setImage (
@@ -279,3 +264,19 @@ function setIdleIcon() {
279264 ) ;
280265 }
281266}
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