浏览代码

changed isFiltering condition + re-activate searchbar on cancel

nayooti 5 年之前
父节点
当前提交
fe043f2c15
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      deltachat-ios/Controller/NewChatViewController.swift

+ 8 - 2
deltachat-ios/Controller/NewChatViewController.swift

@@ -39,7 +39,7 @@ class NewChatViewController: UITableViewController {
 
     // searchBar active?
     func isFiltering() -> Bool {
-        return searchController.isActive && !searchBarIsEmpty()
+        return !searchBarIsEmpty()
     }
 
     // weak var chatDisplayer: ChatDisplayer?
@@ -300,11 +300,17 @@ class NewChatViewController: UITableViewController {
             self.coordinator?.showNewChat(contactId: contactId)
         }))
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: { _ in
-            self.dismiss(animated: true, completion: nil)
+            self.reactivateSearchBarIfNeeded()
         }))
         present(alert, animated: true, completion: nil)
     }
 
+    private func reactivateSearchBarIfNeeded() {
+        if !searchBarIsEmpty() {
+            searchController.isActive = true
+        }
+    }
+
     private func showChatAt(row: Int) {
         if searchController.isActive {
             // edge case: when searchController is active but searchBar is empty -> filteredContacts is empty, so we fallback to contactIds