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 {
|
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
|
||||||
|
coordinator.beginSearching()
|
||||||
searchBar.showsScopeBar = true
|
searchBar.showsScopeBar = true
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchBarShouldEndEditing(_ searchBar: UISearchBar) -> Bool {
|
func searchBarShouldEndEditing(_ searchBar: UISearchBar) -> Bool {
|
||||||
|
coordinator.endSearching()
|
||||||
searchBar.showsScopeBar = false
|
searchBar.showsScopeBar = false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -530,25 +530,27 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchArticles(_ searchString: String, _ searchScope: SearchScope) {
|
func beginSearching() {
|
||||||
guard !searchString.isEmpty else {
|
isSearching = true
|
||||||
isSearching = false
|
searchArticleIds = Set(articles.map { $0.articleID })
|
||||||
lastSearchString = ""
|
timelineFetcher = nil
|
||||||
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 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 {
|
if searchString.count < 3 {
|
||||||
timelineFetcher = nil
|
timelineFetcher = nil
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user