Răsfoiți Sursa

add observers in viewDidAppear since they get removed on viewDidDisappear

cyberta 4 ani în urmă
părinte
comite
737734c92b
1 a modificat fișierele cu 12 adăugiri și 11 ștergeri
  1. 12 11
      deltachat-ios/Chat/ChatViewController.swift

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

@@ -212,6 +212,18 @@ class ChatViewController: UITableViewController {
             updateTitle(chat: dcContext.getChat(chatId: chatId))
         }
 
+        loadMessages()
+
+        if RelayHelper.sharedInstance.isForwarding() {
+            askToForwardMessage()
+        }
+
+    }
+
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+        AppStateRestorer.shared.storeLastActiveChat(chatId: chatId)
+
         let nc = NotificationCenter.default
         msgChangedObserver = nc.addObserver(
             forName: dcNotificationChanged,
@@ -261,17 +273,6 @@ class ChatViewController: UITableViewController {
             self.updateTitle(chat: self.dcContext.getChat(chatId: self.chatId))
         }
 
-        loadMessages()
-
-        if RelayHelper.sharedInstance.isForwarding() {
-            askToForwardMessage()
-        }
-    }
-
-    override func viewDidAppear(_ animated: Bool) {
-        super.viewDidAppear(animated)
-        AppStateRestorer.shared.storeLastActiveChat(chatId: chatId)
-
         // things that do not affect the chatview
         // and are delayed after the view is displayed
         DispatchQueue.global(qos: .background).async { [weak self] in