Sfoglia il codice sorgente

reuse appCoordinator's ability to show an arbitrary chat at a highlighted message in GalleryViewController's show-in-chat feature

cyberta 4 anni fa
parent
commit
623b14470f
1 ha cambiato i file con 3 aggiunte e 11 eliminazioni
  1. 3 11
      deltachat-ios/Controller/GalleryViewController.swift

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

@@ -305,19 +305,11 @@ private extension GalleryViewController {
 
 
     func redirectToMessage(of indexPath: IndexPath) {
     func redirectToMessage(of indexPath: IndexPath) {
         let msgId = mediaMessageIds[indexPath.row]
         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)
     }
     }
 }
 }