Explorar el Código

added scroll to msg in chat view

nayooti hace 4 años
padre
commit
ff3a6aeb00
Se han modificado 1 ficheros con 10 adiciones y 4 borrados
  1. 10 4
      deltachat-ios/Chat/ChatViewController.swift

+ 10 - 4
deltachat-ios/Chat/ChatViewController.swift

@@ -581,6 +581,14 @@ class ChatViewController: UITableViewController {
         }
         }
     }
     }
 
 
+    func scrollToMessage(msgId: Int, animated: Bool = true) {
+        guard let index = messageIds.firstIndex(of: msgId) else {
+            return
+        }
+        let indexPath = IndexPath(row: index, section: 0)
+        tableView.scrollToRow(at: indexPath, at: .top, animated: animated)
+    }
+
     private func showEmptyStateView(_ show: Bool) {
     private func showEmptyStateView(_ show: Bool) {
         if show {
         if show {
             let dcChat = dcContext.getChat(chatId: chatId)
             let dcChat = dcContext.getChat(chatId: chatId)
@@ -1107,10 +1115,8 @@ extension ChatViewController: BaseMessageCellDelegate {
     @objc func quoteTapped(indexPath: IndexPath) {
     @objc func quoteTapped(indexPath: IndexPath) {
         _ = handleUIMenu()
         _ = handleUIMenu()
         let msg = DcMsg(id: messageIds[indexPath.row])
         let msg = DcMsg(id: messageIds[indexPath.row])
-        if let quoteMsg = msg.quoteMessage,
-           let index = messageIds.firstIndex(of: quoteMsg.id) {
-            let indexPath = IndexPath(row: index, section: 0)
-            tableView.scrollToRow(at: indexPath, at: .top, animated: true)
+        if let quoteMsg = msg.quoteMessage {
+            scrollToMessage(msgId: quoteMsg.id)
         }
         }
     }
     }