Переглянути джерело

open new chat view after long tap on a contact request and selection of 'start chat'

cyberta 5 роки тому
батько
коміт
e89b43dd7d

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

@@ -440,9 +440,10 @@ class ChatViewController: MessagesViewController {
         case NSSelectorFromString("messageStartChat:"):
             let msg = messageList[indexPath.section]
             logger.info("message: Start Chat \(msg.messageId)")
-            _ = msg.createChat()
+            let chat = msg.createChat()
             // TODO: figure out how to properly show the chat after creation
             refreshMessages()
+            coordinator?.showChat(chatId: chat.id)
         case NSSelectorFromString("messageBlock:"):
             let msg = messageList[indexPath.section]
             logger.info("message: Block \(msg.messageId)")

+ 9 - 0
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -424,6 +424,15 @@ class ChatViewCoordinator: NSObject, Coordinator {
         // navigationController.present(nav, animated: true, completion: nil)
     }
 
+    func showChat(chatId: Int) {
+        let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
+        let coordinator = ChatViewCoordinator(dcContext: dcContext, navigationController: navigationController, chatId: chatId)
+        childCoordinators.append(coordinator)
+        chatViewController.coordinator = coordinator
+        navigationController.popToRootViewController(animated: false)
+        navigationController.pushViewController(chatViewController, animated: true)
+    }
+
     private func sendImage(_ image: UIImage) {
         DispatchQueue.global().async {
             if let compressedImage = image.dcCompress() {