Prechádzať zdrojové kódy

Update unread count on initial loading (#101)

Danilo Bargen 8 rokov pred
rodič
commit
065335ab11
1 zmenil súbory, kde vykonal 12 pridanie a 5 odobranie
  1. 12 5
      src/services/webclient.ts

+ 12 - 5
src/services/webclient.ts

@@ -1512,6 +1512,7 @@ export class WebClientService implements threema.WebClientService {
                 this.conversations.updateOrAdd(conversation);
             }
         }
+        this.updateUnreadCount();
         this.registerInitializationStep('conversations');
     }
 
@@ -1573,11 +1574,7 @@ export class WebClientService implements threema.WebClientService {
                 return;
         }
 
-        // Update unread count
-        const totalUnreadCount = this.conversations
-            .get()
-            .reduce((a: number, b: threema.Conversation) => a + b.unreadCount, 0);
-        this.titleService.updateUnreadCount(totalUnreadCount);
+        this.updateUnreadCount();
     }
 
     private _receiveResponseMessages(message: threema.WireMessage): void {
@@ -2343,4 +2340,14 @@ export class WebClientService implements threema.WebClientService {
     public getControllerName(): string {
         return this.currentController;
     }
+
+    /**
+     * Update the unread count in the window title.
+     */
+    private updateUnreadCount(): void {
+        const totalUnreadCount = this.conversations
+            .get()
+            .reduce((a: number, b: threema.Conversation) => a + b.unreadCount, 0);
+        this.titleService.updateUnreadCount(totalUnreadCount);
+    }
 }