Bladeren bron

Merge pull request #1230 from deltachat/notification-viewcontroller-stack

notifications: don't stack chat views
cyBerta 4 jaren geleden
bovenliggende
commit
4591e045f2

+ 1 - 1
deltachat-ios/AppDelegate.swift

@@ -431,7 +431,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             let userInfo = response.notification.request.content.userInfo
              if let chatId = userInfo["chat_id"] as? Int,
                  let msgId = userInfo["message_id"] as? Int {
-                 appCoordinator.showChat(chatId: chatId, msgId: msgId)
+                 appCoordinator.showChat(chatId: chatId, msgId: msgId, animated: false, clearViewControllerStack: true)
              }
         }
 

+ 1 - 2
deltachat-ios/Chat/ChatViewController.swift

@@ -1036,8 +1036,7 @@ class ChatViewController: UITableViewController {
 
     func showChat(chatId: Int) {
         if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
-            navigationController?.popToRootViewController(animated: false)
-            appDelegate.appCoordinator.showChat(chatId: chatId)
+            appDelegate.appCoordinator.showChat(chatId: chatId, clearViewControllerStack: true)
         }
     }
 

+ 1 - 1
deltachat-ios/Controller/QrPageController.swift

@@ -119,7 +119,7 @@ class QrPageController: UIPageViewController, ProgressAlertHandler {
 
     private func showChat(chatId: Int) {
         if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
-            appDelegate.appCoordinator.showChat(chatId: chatId)
+            appDelegate.appCoordinator.showChat(chatId: chatId, animated: false, clearViewControllerStack: true)
         }
     }
 }

+ 4 - 1
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -85,9 +85,12 @@ class AppCoordinator {
         tabBarController.selectedIndex = index
     }
 
-    func showChat(chatId: Int, msgId: Int? = nil, animated: Bool = true) {
+    func showChat(chatId: Int, msgId: Int? = nil, animated: Bool = true, clearViewControllerStack: Bool = false) {
         showTab(index: chatsTab)
         if let rootController = self.chatsNavController.viewControllers.first as? ChatListController {
+            if clearViewControllerStack {
+                self.chatsNavController.popToRootViewController(animated: false)
+            }
             rootController.showChat(chatId: chatId, highlightedMsg: msgId, animated: animated)
         }
     }