Selaa lähdekoodia

Merge pull request #1270 from deltachat/fix_show_in_chat

Fix show in chat
bjoern 4 vuotta sitten
vanhempi
commit
886023d618

+ 3 - 11
deltachat-ios/Controller/DocumentGalleryController.swift

@@ -169,18 +169,10 @@ extension DocumentGalleryController {
 
     func redirectToMessage(of indexPath: IndexPath) {
         let msgId = fileMessageIds[indexPath.row]
+        let chatId = dcContext.getMessage(id: msgId).chatId
 
-        guard
-            let chatViewController = navigationController?.viewControllers.filter({ $0 is ChatViewController}).first as? ChatViewController,
-            let chatListController = navigationController?.viewControllers.filter({ $0 is ChatListController}).first as? ChatListController
-        else {
-            safe_fatalError("failed to retrieve chatViewController, chatListController in navigation stack")
-            return
+        if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
+            appDelegate.appCoordinator.showChat(chatId: chatId, msgId: msgId, animated: false, clearViewControllerStack: true)
         }
-        self.navigationController?.viewControllers.remove(at: 1)
-        
-        chatViewController.highlightedMsg = msgId
-        self.navigationController?.pushViewController(chatViewController, animated: true)
-        self.navigationController?.setViewControllers([chatListController, chatViewController], animated: false)
     }
 }

+ 3 - 11
deltachat-ios/Controller/GalleryViewController.swift

@@ -305,19 +305,11 @@ private extension GalleryViewController {
 
     func redirectToMessage(of indexPath: IndexPath) {
         let msgId = mediaMessageIds[indexPath.row]
+        let chatId = dcContext.getMessage(id: msgId).chatId
 
-        guard
-            let chatViewController = navigationController?.viewControllers.filter({ $0 is ChatViewController}).first as? ChatViewController,
-            let chatListController = navigationController?.viewControllers.filter({ $0 is ChatListController}).first as? ChatListController
-        else {
-            safe_fatalError("failed to retrieve chatViewController, chatListController in navigation stack")
-            return
+        if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
+            appDelegate.appCoordinator.showChat(chatId: chatId, msgId: msgId, animated: false, clearViewControllerStack: true)
         }
-        self.navigationController?.viewControllers.remove(at: 1)
-
-        chatViewController.highlightedMsg = msgId
-        self.navigationController?.pushViewController(chatViewController, animated: true)
-        self.navigationController?.setViewControllers([chatListController, chatViewController], animated: false)
     }
 }