Эх сурвалжийг харах

altered contact cell data moded by chatId attribute - contact cell taps navigate to chat if possible without asking

nayooti 5 жил өмнө
parent
commit
45822f9158

+ 5 - 1
deltachat-ios/Controller/ChatListController.swift

@@ -226,7 +226,11 @@ class ChatListController: UITableViewController {
             }
         case .CONTACT(let contactData):
             let contactId = contactData.contactId
-            self.askToChatWith(contactId: contactId)
+            if let chatId = contactData.chatId {
+                coordinator?.showChat(chatId: chatId)
+            } else {
+                self.askToChatWith(contactId: contactId)
+            }
         }
     }
 

+ 5 - 1
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -253,7 +253,11 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
                 safe_fatalError("could not dequeue contactCell cell")
                 break
             }
-            let cellData = ContactCellData(contactId: getGroupMemberIdFor(row))
+            let contactId: Int = getGroupMemberIdFor(row)
+            let cellData = ContactCellData(
+                contactId: contactId,
+                chatId: context.getChatIdByContactId(contactId)
+            )
             let cellViewModel = ContactCellViewModel(contactData: cellData)
             contactCell.updateCell(cellViewModel: cellViewModel)
             return contactCell

+ 4 - 3
deltachat-ios/ViewModel/ChatListViewModel.swift

@@ -19,7 +19,7 @@ protocol ChatListViewModelProtocol: class, UISearchResultsUpdating {
     func beginSearch()
     func endSearch()
     func titleForHeaderIn(section: Int) -> String? // only visible on search results
-
+    
     /// returns ROW of table
     func deleteChat(chatId: Int) -> Int
     func archiveChatToggle(chatId: Int)
@@ -233,11 +233,12 @@ private extension ChatListViewModel {
         let contact = DcContact(id: contactId)
         let nameIndexes = contact.displayName.containsExact(subSequence: searchText)
         let emailIndexes = contact.email.containsExact(subSequence: searchText)
-
+        let chatId: Int? = dcContext.getChatIdByContactId(contactId)
         // contact contains searchText
         let viewModel = ContactCellViewModel(
             contactData: ContactCellData(
-                contactId: contact.id
+                contactId: contact.id,
+                chatId: chatId
             ),
             titleHighlightIndexes: nameIndexes,
             subtitleHighlightIndexes: emailIndexes

+ 1 - 0
deltachat-ios/ViewModel/ContactCellViewModel.swift

@@ -19,6 +19,7 @@ enum CellModel {
 
 struct ContactCellData {
     let contactId: Int
+    let chatId: Int?
 }
 
 struct ChatCellData {