@@ -99,18 +99,7 @@ app.on('ready', () => {
99
99
} ) ;
100
100
} ) ;
101
101
102
- function getMessageCount ( conversations : Conversation [ ] ) : number {
103
- return conversations . filter ( ( { unread} ) => unread ) . length ;
104
- }
105
-
106
- async function updateBadge ( conversations : Conversation [ ] ) : Promise < void > {
107
- // Ignore `Sindre messaged you` blinking
108
- if ( ! Array . isArray ( conversations ) ) {
109
- return ;
110
- }
111
-
112
- const messageCount = getMessageCount ( conversations ) ;
113
-
102
+ async function updateBadge ( messageCount : number ) : Promise < void > {
114
103
if ( ! is . windows ) {
115
104
if ( config . get ( 'showUnreadBadge' ) && ! isDNDEnabled ) {
116
105
app . badgeCount = messageCount ;
@@ -154,16 +143,6 @@ function updateOverlayIcon({data, text}: {data: string; text: string}): void {
154
143
mainWindow . setOverlayIcon ( img , text ) ;
155
144
}
156
145
157
- function updateTrayIcon ( ) : void {
158
- if ( ! config . get ( 'showTrayIcon' ) || config . get ( 'quitOnWindowClose' ) ) {
159
- tray . destroy ( ) ;
160
- } else {
161
- tray . create ( mainWindow ) ;
162
- }
163
- }
164
-
165
- ipc . answerRenderer ( 'update-tray-icon' , updateTrayIcon ) ;
166
-
167
146
interface BeforeSendHeadersResponse {
168
147
cancel ?: boolean ;
169
148
requestHeaders ?: Record < string , string > ;
@@ -437,8 +416,8 @@ function createMainWindow(): BrowserWindow {
437
416
}
438
417
439
418
// Update badge on conversations change
440
- ipc . answerRenderer ( 'conversations ' , async ( conversations : Conversation [ ] ) => {
441
- updateBadge ( conversations ) ;
419
+ ipc . answerRenderer ( 'update-tray-icon ' , async ( messageCount : number ) => {
420
+ updateBadge ( messageCount ) ;
442
421
} ) ;
443
422
444
423
enableHiresResources ( ) ;
0 commit comments