mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-20 14:33:04 +01:00
Made article search go fast
This commit is contained in:
parent
8002839941
commit
67b9721a10
@ -49,6 +49,7 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
private var expandedNodes = [Node]()
|
||||
private var shadowTable = [[Node]]()
|
||||
private var lastSearchString = ""
|
||||
private var isSearching: Bool = false
|
||||
|
||||
private(set) var sortDirection = AppDefaults.timelineSortDirection {
|
||||
didSet {
|
||||
@ -105,14 +106,23 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
|
||||
var timelineFetcher: ArticleFetcher? {
|
||||
didSet {
|
||||
|
||||
currentArticleIndexPath = nil
|
||||
if timelineFetcher is Feed {
|
||||
showFeedNames = false
|
||||
} else {
|
||||
showFeedNames = true
|
||||
}
|
||||
fetchAndReplaceArticlesSync()
|
||||
masterTimelineViewController?.reinitializeArticles()
|
||||
|
||||
if isSearching {
|
||||
fetchAndReplaceArticlesAsync {
|
||||
self.masterTimelineViewController?.reinitializeArticles()
|
||||
}
|
||||
} else {
|
||||
fetchAndReplaceArticlesSync()
|
||||
masterTimelineViewController?.reinitializeArticles()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -506,12 +516,20 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
|
||||
func searchArticles(_ searchString: String) {
|
||||
guard !searchString.isEmpty else {
|
||||
isSearching = false
|
||||
if let ip = currentMasterIndexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher {
|
||||
timelineFetcher = fetcher
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
isSearching = true
|
||||
|
||||
if searchString.count < 3 {
|
||||
timelineFetcher = nil
|
||||
return
|
||||
}
|
||||
|
||||
if searchString != lastSearchString {
|
||||
timelineFetcher = SmartFeed(delegate: SearchFeedDelegate(searchString: searchString))
|
||||
lastSearchString = searchString
|
||||
@ -890,7 +908,7 @@ private extension AppCoordinator {
|
||||
|
||||
func emptyTheTimeline() {
|
||||
if !articles.isEmpty {
|
||||
articles = [Article]()
|
||||
replaceArticles(with: Set<Article>(), animate: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user