@@ -70,7 +70,7 @@ where Cell.SearchModel == Command.CellViewModel {
7070 /// Returns the active Keyword
7171 ///
7272 private var keyword : String {
73- return searchUICommand . sanitizeKeyword ( searchBar. text ?? String ( ) )
73+ return searchBar. text ?? String ( )
7474 }
7575
7676 /// UI Active State
@@ -205,8 +205,7 @@ where Cell.SearchModel == Command.CellViewModel {
205205 // MARK: - UISearchBarDelegate Conformance
206206 //
207207 func searchBar( _ searchBar: UISearchBar , textDidChange searchText: String ) {
208- let sanitizedSearchText = searchUICommand. sanitizeKeyword ( searchText)
209- synchronizeSearchResults ( with: sanitizedSearchText)
208+ synchronizeSearchResults ( with: searchText)
210209 }
211210
212211 func searchBarShouldBeginEditing( _ searchBar: UISearchBar ) -> Bool {
@@ -363,14 +362,14 @@ extension SearchViewController: SyncingCoordinatorDelegate {
363362 /// Synchronizes the models for the Default Store (if any).
364363 ///
365364 func sync( pageNumber: Int , pageSize: Int , reason: String ? , onCompletion: ( ( Bool ) -> Void ) ? = nil ) {
366- let keyword = self . keyword
365+ let keyword = searchUICommand . sanitizeKeyword ( self . keyword)
367366 searchUICommand. synchronizeModels ( siteID: storeID,
368367 keyword: keyword,
369368 pageNumber: pageNumber,
370369 pageSize: pageSize,
371- onCompletion: { [ weak self] isCompleted in
370+ onCompletion: { [ weak self] isCompleted in
372371 // Disregard OPs that don't really match the latest keyword
373- if keyword == self ? . keyword {
372+ if keyword == self ? . searchUICommand . sanitizeKeyword ( self ? . keyword ?? String ( ) ) {
374373 self ? . transitionToResultsUpdatedState ( )
375374 }
376375 onCompletion ? ( isCompleted)
@@ -388,6 +387,7 @@ private extension SearchViewController {
388387 ///
389388 func synchronizeSearchResults( with keyword: String ) {
390389 // When the search query changes, also includes the original results predicate in addition to the search keyword.
390+ let keyword = searchUICommand. sanitizeKeyword ( keyword)
391391 let searchResultsPredicate = NSPredicate ( format: " ANY searchResults.keyword = %@ " , keyword)
392392 let subpredicates = [ resultsPredicate ] . compactMap { $0 } + [ searchResultsPredicate]
393393 resultsController. predicate = NSCompoundPredicate ( andPredicateWithSubpredicates: subpredicates)
0 commit comments