Clear the timeline when the user begins searching
This commit is contained in:
parent
a5298f0381
commit
dfc3046bf0
|
@ -427,11 +427,13 @@ extension MasterTimelineViewController: UISearchBarDelegate {
|
|||
}
|
||||
|
||||
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
|
||||
coordinator.beginSearching()
|
||||
searchBar.showsScopeBar = true
|
||||
return true
|
||||
}
|
||||
|
||||
func searchBarShouldEndEditing(_ searchBar: UISearchBar) -> Bool {
|
||||
coordinator.endSearching()
|
||||
searchBar.showsScopeBar = false
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -530,25 +530,27 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||
|
||||
}
|
||||
|
||||
func searchArticles(_ searchString: String, _ searchScope: SearchScope) {
|
||||
guard !searchString.isEmpty else {
|
||||
isSearching = false
|
||||
lastSearchString = ""
|
||||
lastSearchScope = nil
|
||||
searchArticleIds = nil
|
||||
|
||||
if let ip = currentMasterIndexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher {
|
||||
timelineFetcher = fetcher
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if !isSearching {
|
||||
isSearching = true
|
||||
searchArticleIds = Set(articles.map { $0.articleID })
|
||||
}
|
||||
func beginSearching() {
|
||||
isSearching = true
|
||||
searchArticleIds = Set(articles.map { $0.articleID })
|
||||
timelineFetcher = nil
|
||||
}
|
||||
|
||||
func endSearching() {
|
||||
isSearching = false
|
||||
lastSearchString = ""
|
||||
lastSearchScope = nil
|
||||
searchArticleIds = nil
|
||||
|
||||
if let ip = currentMasterIndexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher {
|
||||
timelineFetcher = fetcher
|
||||
}
|
||||
}
|
||||
|
||||
func searchArticles(_ searchString: String, _ searchScope: SearchScope) {
|
||||
|
||||
guard isSearching else { return }
|
||||
|
||||
if searchString.count < 3 {
|
||||
timelineFetcher = nil
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue