Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Disabled auto-completion while user doing backspacing
- Loading branch information
Showing
with
13 additions
and
1 deletion.
-
+13
−1
Cliqz/Search/CliqzSearchViewController.swift
|
|
@@ -48,7 +48,13 @@ class CliqzSearchViewController : UIViewController, KeyboardHelperDelegate, UIAl |
|
|
|
|
|
weak var delegate: SearchViewDelegate? |
|
|
|
|
|
var searchQuery: String? = nil |
|
|
var lastSearchQuery: String? = nil |
|
|
|
|
|
var searchQuery: String? = nil { |
|
|
willSet { |
|
|
lastSearchQuery = searchQuery |
|
|
} |
|
|
} |
|
|
|
|
|
var profile: Profile |
|
|
|
|
|
@@ -232,6 +238,12 @@ extension CliqzSearchViewController { |
|
|
//MARK: - Autocomplete Notification |
|
|
extension CliqzSearchViewController { |
|
|
@objc func autocomplete(_ notification: Notification) { |
|
|
|
|
|
if let searchQuery = searchQuery, let lastSearchQuery = lastSearchQuery, searchQuery.count < lastSearchQuery.count { |
|
|
// don't call auto complete if user is backspacing |
|
|
return |
|
|
} |
|
|
|
|
|
if let str = notification.object as? String { |
|
|
delegate?.autoCompeleteQuery(str) |
|
|
} |
|
|
|