Browse Source

issues with searchbar state when ask to chat with dialogue pops up

nayooti 5 years ago
parent
commit
4b67342444

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

@@ -296,22 +296,22 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
     private func askToChatWith(contactId: Int) {
         assert(searchController.isActive)
         searchController.searchBar.text = nil
-        searchController.dismiss(animated: false) {
-            let dcContact = DcContact(id: contactId)
-            let alert = UIAlertController(title: String.localizedStringWithFormat(String.localized("ask_start_chat_with"), dcContact.nameNAddr),
-                                          message: nil,
-                                          preferredStyle: .safeActionSheet)
-            alert.addAction(UIAlertAction(title: String.localized("start_chat"), style: .default, handler: { _ in
+
+        let dcContact = DcContact(id: contactId)
+        let alert = UIAlertController(title: String.localizedStringWithFormat(String.localized("ask_start_chat_with"), dcContact.nameNAddr),
+                                      message: nil,
+                                      preferredStyle: .safeActionSheet)
+        alert.addAction(UIAlertAction(title: String.localized("start_chat"), style: .default, handler: { _ in
+            self.searchController.dismiss(animated: false) {
                 self.dismiss(animated: true, completion: nil)
                 self.coordinator?.showNewChat(contactId: contactId)
-            }))
-            alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: { _ in
-                self.dismiss(animated: true, completion: nil)
-            }))
-            self.present(alert, animated: true, completion: nil)
-        }
+            }
+        }))
+        alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: { _ in
+            self.dismiss(animated: true, completion: nil)
+        }))
+        self.present(alert, animated: true, completion: nil)
     }
-
 }
 
 
@@ -321,7 +321,7 @@ extension ChatListController: UISearchBarDelegate {
         return true
     }
 
-    func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
+    func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
         viewModel.endFiltering()
     }
 }

+ 2 - 1
deltachat-ios/ViewModel/ChatListViewModel.swift

@@ -39,7 +39,8 @@ protocol ChatListViewModelProtocol: class, UISearchResultsUpdating {
     func getCellViewModelFor(indexPath: IndexPath) -> AvatarCellViewModel
     func beginFiltering()
     func endFiltering()
-
+    var searchActive: Bool { get }
+    
     func archieveChat(chatId: Int)
     func deleteChat(chatId: Int)
 }