瀏覽代碼

Merge pull request #368 from deltachat/noticed-on-appear

marknoticed and update badge on entering chat
cyBerta 5 年之前
父節點
當前提交
53a4779344
共有 1 個文件被更改,包括 10 次插入5 次删除
  1. 10 5
      deltachat-ios/Controller/ChatViewController.swift

+ 10 - 5
deltachat-ios/Controller/ChatViewController.swift

@@ -59,8 +59,6 @@ class ChatViewController: MessagesViewController {
     }
 
     override func viewDidLoad() {
-        dcContext.marknoticedChat(chatId: chatId)
-
         messagesCollectionView.register(CustomMessageCell.self)
         super.viewDidLoad()
         if !DcConfig.configured {
@@ -151,14 +149,21 @@ class ChatViewController: MessagesViewController {
         }
     }
 
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+
+        // things that do not affect the chatview
+        // and are delayed after the view is displayed
+        dcContext.marknoticedChat(chatId: chatId)
+        let array = DcArray(arrayPointer: dc_get_fresh_msgs(mailboxPointer))
+        UIApplication.shared.applicationIconBadgeNumber = array.count
+    }
+
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
 
         // the navigationController will be used when chatDetail is pushed, so we have to remove that gestureRecognizer
         navigationController?.navigationBar.removeGestureRecognizer(navBarTap)
-
-        let array = DcArray(arrayPointer: dc_get_fresh_msgs(mailboxPointer))
-        UIApplication.shared.applicationIconBadgeNumber = array.count
     }
 
     override func viewDidDisappear(_ animated: Bool) {