瀏覽代碼

Merge pull request #585 from deltachat/searchAndChatlistFixes

Search and chatlist fixes
cyBerta 5 年之前
父節點
當前提交
1e59230b0a

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

@@ -72,6 +72,7 @@ class ChatListController: UITableViewController {
         viewModel.refreshData()
         viewModel.refreshData()
 
 
         if RelayHelper.sharedInstance.isForwarding() {
         if RelayHelper.sharedInstance.isForwarding() {
+            quitSearch(animated: false)
             tableView.scrollToTop()
             tableView.scrollToTop()
         }
         }
 
 
@@ -146,6 +147,16 @@ class ChatListController: UITableViewController {
         updateTitle()
         updateTitle()
     }
     }
 
 
+    private func quitSearch(animated: Bool) {
+        searchController.searchBar.text = nil
+        self.viewModel.endSearch()
+        searchController.dismiss(animated: animated) {
+            self.tableView.scrollToTop()
+        }
+    }
+
+    // MARK: - UITableViewDelegate + UITableViewDatasource
+
     override func numberOfSections(in tableView: UITableView) -> Int {
     override func numberOfSections(in tableView: UITableView) -> Int {
         return viewModel.numberOfSections
         return viewModel.numberOfSections
     }
     }
@@ -160,7 +171,7 @@ class ChatListController: UITableViewController {
         let cellData = viewModel.cellDataFor(section: indexPath.section, row: indexPath.row)
         let cellData = viewModel.cellDataFor(section: indexPath.section, row: indexPath.row)
 
 
         switch cellData.type {
         switch cellData.type {
-        case .deaddrop(let deaddropData):
+        case .deaddrop:
             guard let deaddropCell = tableView.dequeueReusableCell(withIdentifier: deadDropCellReuseIdentifier, for: indexPath) as? ContactCell else {
             guard let deaddropCell = tableView.dequeueReusableCell(withIdentifier: deadDropCellReuseIdentifier, for: indexPath) as? ContactCell else {
                 break
                 break
             }
             }
@@ -355,6 +366,7 @@ extension ChatListController: UISearchBarDelegate {
     }
     }
 
 
     func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
     func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
+        // searchBar will be set to "" by system
         viewModel.endSearch()
         viewModel.endSearch()
     }
     }
 }
 }

+ 1 - 0
deltachat-ios/View/ContactCell.swift

@@ -247,6 +247,7 @@ class ContactCell: UITableViewCell {
             } else {
             } else {
                 setBackupImage(name: contact.nameNAddr, color: contact.color)
                 setBackupImage(name: contact.nameNAddr, color: contact.color)
             }
             }
+            setTimeLabel(deaddropData.summary.timestamp)
             titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
             titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
 
 
         case .chat(let chatData):
         case .chat(let chatData):

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

@@ -108,14 +108,14 @@ class ChatListViewModel: NSObject, ChatListViewModelProtocol {
         if showSearchResults {
         if showSearchResults {
             switch searchResultSections[section] {
             switch searchResultSections[section] {
             case .chats:
             case .chats:
-                break
+                return makeChatCellViewModel(index: row, searchText: searchText)
             case .contacts:
             case .contacts:
                 return makeContactCellViewModel(contactId: searchResultContactIds[row])
                 return makeContactCellViewModel(contactId: searchResultContactIds[row])
             case .messages:
             case .messages:
                 return makeMessageCellViewModel(msgId: searchResultMessageIds[row])
                 return makeMessageCellViewModel(msgId: searchResultMessageIds[row])
             }
             }
         }
         }
-        return makeChatCellViewModel(index: row, searchText: searchText)
+        return makeChatCellViewModel(index: row, searchText: "")
     }
     }
 
 
     func titleForHeaderIn(section: Int) -> String? {
     func titleForHeaderIn(section: Int) -> String? {
@@ -162,8 +162,8 @@ class ChatListViewModel: NSObject, ChatListViewModelProtocol {
     }
     }
 
 
     func endSearch() {
     func endSearch() {
-        searchText = ""
         searchActive = false
         searchActive = false
+        searchText = ""
         resetSearch()
         resetSearch()
     }
     }