Browse Source

always update chat's title bar badge on message changed event

cyberta 5 years ago
parent
commit
ed5807cbe5
1 changed files with 12 additions and 11 deletions
  1. 12 11
      deltachat-ios/Controller/ChatViewController.swift

+ 12 - 11
deltachat-ios/Controller/ChatViewController.swift

@@ -129,16 +129,6 @@ class ChatViewController: MessagesViewController {
         let chat = DcChat(id: chatId)
         if showCustomNavBar {
             updateTitle(chat: chat)
-
-            let badge: InitialsBadge
-            if let image = chat.profileImage {
-                badge =  InitialsBadge(image: image, size: 28)
-            } else {
-                badge =  InitialsBadge(name: chat.name, color: chat.color, size: 28)
-            }
-            badge.setVerified(chat.isVerified)
-            badge.accessibilityTraits = .button
-            navigationItem.rightBarButtonItem = UIBarButtonItem(customView: badge)
         }
 
         configureMessageMenu()
@@ -161,7 +151,7 @@ class ChatViewController: MessagesViewController {
                         self.refreshMessages()
                     }
                 }
-                if (self.showCustomNavBar) {
+                if self.showCustomNavBar {
                     self.updateTitle(chat: chat)
                 }
             }
@@ -234,8 +224,19 @@ class ChatViewController: MessagesViewController {
                 subtitle = DcContact(id: chatContactIds[0]).email
             }
         }
+        
         titleView.updateTitleView(title: chat.name, subtitle: subtitle)
         navigationItem.titleView = titleView
+
+        let badge: InitialsBadge
+        if let image = chat.profileImage {
+            badge =  InitialsBadge(image: image, size: 28)
+        } else {
+            badge =  InitialsBadge(name: chat.name, color: chat.color, size: 28)
+        }
+        badge.setVerified(chat.isVerified)
+        badge.accessibilityTraits = .button
+        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: badge)
     }
 
     @objc