Bläddra i källkod

Merge pull request #1212 from deltachat/show-in-chat

Show in chat
cyBerta 4 år sedan
förälder
incheckning
d59b4c3ec6

+ 5 - 5
deltachat-ios/Chat/ChatViewController.swift

@@ -748,7 +748,7 @@ class ChatViewController: UITableViewController {
         self.showEmptyStateView(self.messageIds.isEmpty)
     }
 
-    func reloadData() {
+    private func reloadData() {
         let selectredRows = tableView.indexPathsForSelectedRows
         tableView.reloadData()
         // There's an iOS bug, filling up the console output but which can be ignored: https://developer.apple.com/forums/thread/668295
@@ -767,14 +767,14 @@ class ChatViewController: UITableViewController {
         self.reloadData()
     }
 
-    func isLastRowVisible() -> Bool {
+    private func isLastRowVisible() -> Bool {
         guard !messageIds.isEmpty else { return false }
 
         let lastIndexPath = IndexPath(item: messageIds.count - 1, section: 0)
         return tableView.indexPathsForVisibleRows?.contains(lastIndexPath) ?? false
     }
 
-    func scrollToBottom(animated: Bool) {
+    private func scrollToBottom(animated: Bool) {
         if !messageIds.isEmpty {
             DispatchQueue.main.async { [weak self] in
                 guard let self = self else { return }
@@ -786,7 +786,7 @@ class ChatViewController: UITableViewController {
         }
     }
 
-    func scrollToMessage(msgId: Int, animated: Bool = true) {
+    private func scrollToMessage(msgId: Int, animated: Bool = true) {
         DispatchQueue.main.async { [weak self] in
             guard let self = self else { return }
             guard let index = self.messageIds.firstIndex(of: msgId) else {
@@ -855,7 +855,7 @@ class ChatViewController: UITableViewController {
         configureInputBarItems()
     }
 
-    func evaluateInputBar(draft: DraftModel) {
+    private func evaluateInputBar(draft: DraftModel) {
         messageInputBar.sendButton.isEnabled = draft.canSend()
     }
 

+ 2 - 2
deltachat-ios/Controller/ChatListController.swift

@@ -442,13 +442,13 @@ class ChatListController: UITableViewController {
 
     private func deleteChat(chatId: Int, animated: Bool) {
         if !animated {
-            _ = viewModel.deleteChat(chatId: chatId)
+            viewModel.deleteChat(chatId: chatId)
             refreshInBg()
             return
         }
 
         if viewModel.searchActive {
-            _ = viewModel.deleteChat(chatId: chatId)
+            viewModel.deleteChat(chatId: chatId)
             viewModel.refreshData()
             viewModel.updateSearchResults(for: searchController)
             return

+ 4 - 4
deltachat-ios/Controller/DocumentGalleryController.swift

@@ -171,16 +171,16 @@ extension DocumentGalleryController {
         let msgId = fileMessageIds[indexPath.row]
 
         guard
-            let chatViewController = navigationController?.viewControllers.filter ({ $0 is ChatViewController}).first as? ChatViewController,
+            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("failt to retrieve chatViewController, chatListController in navigation stack")
+            safe_fatalError("failed to retrieve chatViewController, chatListController in navigation stack")
             return
         }
         self.navigationController?.viewControllers.remove(at: 1)
-
+        
+        chatViewController.highlightedMsg = msgId
         self.navigationController?.pushViewController(chatViewController, animated: true)
         self.navigationController?.setViewControllers([chatListController, chatViewController], animated: false)
-        chatViewController.scrollToMessage(msgId: msgId)
     }
 }

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

@@ -305,17 +305,17 @@ private extension GalleryViewController {
         let msgId = mediaMessageIds[indexPath.row]
 
         guard
-            let chatViewController = navigationController?.viewControllers.filter ({ $0 is ChatViewController}).first as? ChatViewController,
+            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("failt to retrieve chatViewController, chatListController in navigation stack")
+            safe_fatalError("failed to retrieve chatViewController, chatListController in navigation stack")
             return
         }
         self.navigationController?.viewControllers.remove(at: 1)
 
+        chatViewController.highlightedMsg = msgId
         self.navigationController?.pushViewController(chatViewController, animated: true)
         self.navigationController?.setViewControllers([chatListController, chatViewController], animated: false)
-        chatViewController.scrollToMessage(msgId: msgId)
     }
 }