mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-18 04:20:39 +01:00
Rename callback: to completion:
This commit is contained in:
parent
43bf65b7a6
commit
58b24f3349
@ -642,45 +642,45 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
}
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(_ fetchType: FetchType, _ callback: @escaping ArticleSetBlock) {
|
||||
public func fetchArticlesAsync(_ fetchType: FetchType, _ completion: @escaping ArticleSetBlock) {
|
||||
switch fetchType {
|
||||
case .starred:
|
||||
fetchStarredArticlesAsync(callback)
|
||||
fetchStarredArticlesAsync(completion)
|
||||
case .unread:
|
||||
fetchUnreadArticlesAsync(callback)
|
||||
fetchUnreadArticlesAsync(completion)
|
||||
case .today:
|
||||
fetchTodayArticlesAsync(callback)
|
||||
fetchTodayArticlesAsync(completion)
|
||||
case .folder(let folder, let readFilter):
|
||||
if readFilter {
|
||||
return fetchUnreadArticlesAsync(folder: folder, callback)
|
||||
return fetchUnreadArticlesAsync(folder: folder, completion)
|
||||
} else {
|
||||
return fetchArticlesAsync(folder: folder, callback)
|
||||
return fetchArticlesAsync(folder: folder, completion)
|
||||
}
|
||||
case .webFeed(let webFeed):
|
||||
fetchArticlesAsync(webFeed: webFeed, callback)
|
||||
fetchArticlesAsync(webFeed: webFeed, completion)
|
||||
case .articleIDs(let articleIDs):
|
||||
fetchArticlesAsync(articleIDs: articleIDs, callback)
|
||||
fetchArticlesAsync(articleIDs: articleIDs, completion)
|
||||
case .search(let searchString):
|
||||
fetchArticlesMatchingAsync(searchString, callback)
|
||||
fetchArticlesMatchingAsync(searchString, completion)
|
||||
case .searchWithArticleIDs(let searchString, let articleIDs):
|
||||
return fetchArticlesMatchingWithArticleIDsAsync(searchString, articleIDs, callback)
|
||||
return fetchArticlesMatchingWithArticleIDsAsync(searchString, articleIDs, completion)
|
||||
}
|
||||
}
|
||||
|
||||
public func fetchUnreadCountForToday(_ callback: @escaping (Int) -> Void) {
|
||||
database.fetchUnreadCountForToday(for: flattenedWebFeeds().webFeedIDs(), callback: callback)
|
||||
public func fetchUnreadCountForToday(_ completion: @escaping (Int) -> Void) {
|
||||
database.fetchUnreadCountForToday(for: flattenedWebFeeds().webFeedIDs(), completion: completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadCountForStarredArticles(_ callback: @escaping (Int) -> Void) {
|
||||
database.fetchStarredAndUnreadCount(for: flattenedWebFeeds().webFeedIDs(), callback: callback)
|
||||
public func fetchUnreadCountForStarredArticles(_ completion: @escaping (Int) -> Void) {
|
||||
database.fetchStarredAndUnreadCount(for: flattenedWebFeeds().webFeedIDs(), completion: completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
|
||||
database.fetchUnreadArticleIDsAsync(webFeedIDs: flattenedWebFeeds().webFeedIDs(), callback: callback)
|
||||
public func fetchUnreadArticleIDs(_ completion: @escaping (Set<String>) -> Void) {
|
||||
database.fetchUnreadArticleIDsAsync(webFeedIDs: flattenedWebFeeds().webFeedIDs(), completion: completion)
|
||||
}
|
||||
|
||||
public func fetchStarredArticleIDs(_ callback: @escaping (Set<String>) -> Void) {
|
||||
database.fetchStarredArticleIDsAsync(webFeedIDs: flattenedWebFeeds().webFeedIDs(), callback: callback)
|
||||
public func fetchStarredArticleIDs(_ completion: @escaping (Set<String>) -> Void) {
|
||||
database.fetchStarredArticleIDsAsync(webFeedIDs: flattenedWebFeeds().webFeedIDs(), completion: completion)
|
||||
}
|
||||
|
||||
public func fetchArticleIDsForStatusesWithoutArticles() -> Set<String> {
|
||||
@ -770,7 +770,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
/// Fetch statuses for the specified articleIDs. The completion handler will get nil if the app is suspended.
|
||||
/// To update the properties in the database, call the update method that takes Set<ArticleStatus> as first parameter.
|
||||
func fetchStatuses(articleIDs: Set<String>, createIfNeeded: Bool, completion: @escaping (Set<ArticleStatus>?) -> Void) {
|
||||
database.fetchStatuses(articleIDs: articleIDs, createIfNeeded: createIfNeeded, callback: completion)
|
||||
database.fetchStatuses(articleIDs: articleIDs, createIfNeeded: createIfNeeded, completion: completion)
|
||||
}
|
||||
|
||||
/// Empty caches that can reasonably be emptied. Call when the app goes in the background, for instance.
|
||||
@ -923,40 +923,40 @@ private extension Account {
|
||||
return database.fetchStarredArticles(flattenedWebFeeds().webFeedIDs())
|
||||
}
|
||||
|
||||
func fetchStarredArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
database.fetchedStarredArticlesAsync(flattenedWebFeeds().webFeedIDs(), callback)
|
||||
func fetchStarredArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
database.fetchedStarredArticlesAsync(flattenedWebFeeds().webFeedIDs(), completion)
|
||||
}
|
||||
|
||||
func fetchUnreadArticles() -> Set<Article> {
|
||||
return fetchUnreadArticles(forContainer: self)
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
fetchUnreadArticlesAsync(forContainer: self, callback)
|
||||
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
fetchUnreadArticlesAsync(forContainer: self, completion)
|
||||
}
|
||||
|
||||
func fetchTodayArticles() -> Set<Article> {
|
||||
return database.fetchTodayArticles(flattenedWebFeeds().webFeedIDs())
|
||||
}
|
||||
|
||||
func fetchTodayArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
database.fetchTodayArticlesAsync(flattenedWebFeeds().webFeedIDs(), callback)
|
||||
func fetchTodayArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
database.fetchTodayArticlesAsync(flattenedWebFeeds().webFeedIDs(), completion)
|
||||
}
|
||||
|
||||
func fetchArticles(folder: Folder) -> Set<Article> {
|
||||
return fetchArticles(forContainer: folder)
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(folder: Folder, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync(forContainer: folder, callback)
|
||||
func fetchArticlesAsync(folder: Folder, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync(forContainer: folder, completion)
|
||||
}
|
||||
|
||||
func fetchUnreadArticles(folder: Folder) -> Set<Article> {
|
||||
return fetchUnreadArticles(forContainer: folder)
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(folder: Folder, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchUnreadArticlesAsync(forContainer: folder, callback)
|
||||
func fetchUnreadArticlesAsync(folder: Folder, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchUnreadArticlesAsync(forContainer: folder, completion)
|
||||
}
|
||||
|
||||
func fetchArticles(webFeed: WebFeed) -> Set<Article> {
|
||||
@ -965,10 +965,10 @@ private extension Account {
|
||||
return articles
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(webFeed: WebFeed, _ callback: @escaping ArticleSetBlock) {
|
||||
func fetchArticlesAsync(webFeed: WebFeed, _ completion: @escaping ArticleSetBlock) {
|
||||
database.fetchArticlesAsync(webFeed.webFeedID) { [weak self] (articles) in
|
||||
self?.validateUnreadCount(webFeed, articles)
|
||||
callback(articles)
|
||||
completion(articles)
|
||||
}
|
||||
}
|
||||
|
||||
@ -980,20 +980,20 @@ private extension Account {
|
||||
return database.fetchArticlesMatchingWithArticleIDs(searchString, articleIDs)
|
||||
}
|
||||
|
||||
func fetchArticlesMatchingAsync(_ searchString: String, _ callback: @escaping ArticleSetBlock) {
|
||||
database.fetchArticlesMatchingAsync(searchString, flattenedWebFeeds().webFeedIDs(), callback)
|
||||
func fetchArticlesMatchingAsync(_ searchString: String, _ completion: @escaping ArticleSetBlock) {
|
||||
database.fetchArticlesMatchingAsync(searchString, flattenedWebFeeds().webFeedIDs(), completion)
|
||||
}
|
||||
|
||||
func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
database.fetchArticlesMatchingWithArticleIDsAsync(searchString, articleIDs, callback)
|
||||
func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
database.fetchArticlesMatchingWithArticleIDsAsync(searchString, articleIDs, completion)
|
||||
}
|
||||
|
||||
func fetchArticles(articleIDs: Set<String>) -> Set<Article> {
|
||||
return database.fetchArticles(articleIDs: articleIDs)
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(articleIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
return database.fetchArticlesAsync(articleIDs: articleIDs, callback)
|
||||
func fetchArticlesAsync(articleIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
return database.fetchArticlesAsync(articleIDs: articleIDs, completion)
|
||||
}
|
||||
|
||||
func fetchUnreadArticles(webFeed: WebFeed) -> Set<Article> {
|
||||
@ -1002,7 +1002,7 @@ private extension Account {
|
||||
return articles
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(for webFeed: WebFeed, callback: @escaping (Set<Article>) -> Void) {
|
||||
func fetchUnreadArticlesAsync(for webFeed: WebFeed, completion: @escaping (Set<Article>) -> Void) {
|
||||
// database.fetchUnreadArticlesAsync(for: Set([feed.feedID])) { [weak self] (articles) in
|
||||
// self?.validateUnreadCount(feed, articles)
|
||||
// callback(articles)
|
||||
@ -1017,11 +1017,11 @@ private extension Account {
|
||||
return articles
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(forContainer container: Container, _ callback: @escaping ArticleSetBlock) {
|
||||
func fetchArticlesAsync(forContainer container: Container, _ completion: @escaping ArticleSetBlock) {
|
||||
let webFeeds = container.flattenedWebFeeds()
|
||||
database.fetchArticlesAsync(webFeeds.webFeedIDs()) { [weak self] (articles) in
|
||||
self?.validateUnreadCountsAfterFetchingUnreadArticles(webFeeds, articles)
|
||||
callback(articles)
|
||||
completion(articles)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1032,11 +1032,11 @@ private extension Account {
|
||||
return articles
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(forContainer container: Container, _ callback: @escaping ArticleSetBlock) {
|
||||
func fetchUnreadArticlesAsync(forContainer container: Container, _ completion: @escaping ArticleSetBlock) {
|
||||
let webFeeds = container.flattenedWebFeeds()
|
||||
database.fetchUnreadArticlesAsync(webFeeds.webFeedIDs()) { [weak self] (articles) in
|
||||
self?.validateUnreadCountsAfterFetchingUnreadArticles(webFeeds, articles)
|
||||
callback(articles)
|
||||
completion(articles)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ public final class AccountManager: UnreadCountProvider {
|
||||
return articles
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(_ fetchType: FetchType, _ callback: @escaping ArticleSetBlock) {
|
||||
public func fetchArticlesAsync(_ fetchType: FetchType, _ completion: @escaping ArticleSetBlock) {
|
||||
precondition(Thread.isMainThread)
|
||||
|
||||
var allFetchedArticles = Set<Article>()
|
||||
@ -277,7 +277,7 @@ public final class AccountManager: UnreadCountProvider {
|
||||
allFetchedArticles.formUnion(articles)
|
||||
accountsReporting += 1
|
||||
if accountsReporting == numberOfAccounts {
|
||||
callback(allFetchedArticles)
|
||||
completion(allFetchedArticles)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ import Articles
|
||||
public protocol ArticleFetcher {
|
||||
|
||||
func fetchArticles() -> Set<Article>
|
||||
func fetchArticlesAsync(_ callback: @escaping ArticleSetBlock)
|
||||
func fetchArticlesAsync(_ completion: @escaping ArticleSetBlock)
|
||||
func fetchUnreadArticles() -> Set<Article>
|
||||
func fetchUnreadArticlesAsync(_ callback: @escaping ArticleSetBlock)
|
||||
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock)
|
||||
}
|
||||
|
||||
extension WebFeed: ArticleFetcher {
|
||||
@ -23,26 +23,26 @@ extension WebFeed: ArticleFetcher {
|
||||
return account?.fetchArticles(.webFeed(self)) ?? Set<Article>()
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
public func fetchArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
guard let account = account else {
|
||||
assertionFailure("Expected feed.account, but got nil.")
|
||||
callback(Set<Article>())
|
||||
completion(Set<Article>())
|
||||
return
|
||||
}
|
||||
account.fetchArticlesAsync(.webFeed(self), callback)
|
||||
account.fetchArticlesAsync(.webFeed(self), completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadArticles() -> Set<Article> {
|
||||
return fetchArticles().unreadArticles()
|
||||
}
|
||||
|
||||
public func fetchUnreadArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
public func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
guard let account = account else {
|
||||
assertionFailure("Expected feed.account, but got nil.")
|
||||
callback(Set<Article>())
|
||||
completion(Set<Article>())
|
||||
return
|
||||
}
|
||||
account.fetchArticlesAsync(.webFeed(self)) { callback($0.unreadArticles()) }
|
||||
account.fetchArticlesAsync(.webFeed(self)) { completion($0.unreadArticles()) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,13 +56,13 @@ extension Folder: ArticleFetcher {
|
||||
return account.fetchArticles(.folder(self, false))
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
public func fetchArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
guard let account = account else {
|
||||
assertionFailure("Expected folder.account, but got nil.")
|
||||
callback(Set<Article>())
|
||||
completion(Set<Article>())
|
||||
return
|
||||
}
|
||||
account.fetchArticlesAsync(.folder(self, false), callback)
|
||||
account.fetchArticlesAsync(.folder(self, false), completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadArticles() -> Set<Article> {
|
||||
@ -73,12 +73,12 @@ extension Folder: ArticleFetcher {
|
||||
return account.fetchArticles(.folder(self, true))
|
||||
}
|
||||
|
||||
public func fetchUnreadArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
public func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
guard let account = account else {
|
||||
assertionFailure("Expected folder.account, but got nil.")
|
||||
callback(Set<Article>())
|
||||
completion(Set<Article>())
|
||||
return
|
||||
}
|
||||
account.fetchArticlesAsync(.folder(self, true), callback)
|
||||
account.fetchArticlesAsync(.folder(self, true), completion)
|
||||
}
|
||||
}
|
||||
|
@ -23,16 +23,16 @@ public struct SingleArticleFetcher: ArticleFetcher {
|
||||
return account.fetchArticles(.articleIDs(Set([articleID])))
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
return account.fetchArticlesAsync(.articleIDs(Set([articleID])), callback)
|
||||
public func fetchArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
return account.fetchArticlesAsync(.articleIDs(Set([articleID])), completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadArticles() -> Set<Article> {
|
||||
return account.fetchArticles(.articleIDs(Set([articleID])))
|
||||
}
|
||||
|
||||
public func fetchUnreadArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
return account.fetchArticlesAsync(.articleIDs(Set([articleID])), callback)
|
||||
public func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
return account.fetchArticlesAsync(.articleIDs(Set([articleID])), completion)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,58 +87,58 @@ public final class ArticlesDatabase {
|
||||
|
||||
// MARK: - Fetching Articles Async
|
||||
|
||||
public func fetchArticlesAsync(_ webFeedID: String, _ callback: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesAsync(webFeedID, callback)
|
||||
public func fetchArticlesAsync(_ webFeedID: String, _ completion: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesAsync(webFeedID, completion)
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(_ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesAsync(webFeedIDs, callback)
|
||||
public func fetchArticlesAsync(_ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesAsync(webFeedIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchArticlesAsync(articleIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesAsync(articleIDs: articleIDs, callback)
|
||||
public func fetchArticlesAsync(articleIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesAsync(articleIDs: articleIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadArticlesAsync(_ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchUnreadArticlesAsync(webFeedIDs, callback)
|
||||
public func fetchUnreadArticlesAsync(_ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchUnreadArticlesAsync(webFeedIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchTodayArticlesAsync(_ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesSinceAsync(webFeedIDs, todayCutoffDate(), callback)
|
||||
public func fetchTodayArticlesAsync(_ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesSinceAsync(webFeedIDs, todayCutoffDate(), completion)
|
||||
}
|
||||
|
||||
public func fetchedStarredArticlesAsync(_ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchStarredArticlesAsync(webFeedIDs, callback)
|
||||
public func fetchedStarredArticlesAsync(_ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchStarredArticlesAsync(webFeedIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchArticlesMatchingAsync(_ searchString: String, _ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesMatchingAsync(searchString, webFeedIDs, callback)
|
||||
public func fetchArticlesMatchingAsync(_ searchString: String, _ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesMatchingAsync(searchString, webFeedIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesMatchingWithArticleIDsAsync(searchString, articleIDs, callback)
|
||||
public func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
articlesTable.fetchArticlesMatchingWithArticleIDsAsync(searchString, articleIDs, completion)
|
||||
}
|
||||
|
||||
// MARK: - Unread Counts
|
||||
|
||||
public func fetchUnreadCounts(for webFeedIDs: Set<String>, _ callback: @escaping UnreadCountCompletionBlock) {
|
||||
articlesTable.fetchUnreadCounts(webFeedIDs, callback)
|
||||
public func fetchUnreadCounts(for webFeedIDs: Set<String>, _ completion: @escaping UnreadCountCompletionBlock) {
|
||||
articlesTable.fetchUnreadCounts(webFeedIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadCountForToday(for webFeedIDs: Set<String>, callback: @escaping (Int) -> Void) {
|
||||
fetchUnreadCount(for: webFeedIDs, since: todayCutoffDate(), callback: callback)
|
||||
public func fetchUnreadCountForToday(for webFeedIDs: Set<String>, completion: @escaping (Int) -> Void) {
|
||||
fetchUnreadCount(for: webFeedIDs, since: todayCutoffDate(), completion: completion)
|
||||
}
|
||||
|
||||
public func fetchUnreadCount(for webFeedIDs: Set<String>, since: Date, callback: @escaping (Int) -> Void) {
|
||||
articlesTable.fetchUnreadCount(webFeedIDs, since, callback)
|
||||
public func fetchUnreadCount(for webFeedIDs: Set<String>, since: Date, completion: @escaping (Int) -> Void) {
|
||||
articlesTable.fetchUnreadCount(webFeedIDs, since, completion)
|
||||
}
|
||||
|
||||
public func fetchStarredAndUnreadCount(for webFeedIDs: Set<String>, callback: @escaping (Int) -> Void) {
|
||||
articlesTable.fetchStarredAndUnreadCount(webFeedIDs, callback)
|
||||
public func fetchStarredAndUnreadCount(for webFeedIDs: Set<String>, completion: @escaping (Int) -> Void) {
|
||||
articlesTable.fetchStarredAndUnreadCount(webFeedIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchAllNonZeroUnreadCounts(_ callback: @escaping UnreadCountCompletionBlock) {
|
||||
articlesTable.fetchAllUnreadCounts(callback)
|
||||
public func fetchAllNonZeroUnreadCounts(_ completion: @escaping UnreadCountCompletionBlock) {
|
||||
articlesTable.fetchAllUnreadCounts(completion)
|
||||
}
|
||||
|
||||
// MARK: - Saving and Updating Articles
|
||||
@ -155,13 +155,13 @@ public final class ArticlesDatabase {
|
||||
// MARK: - Status
|
||||
|
||||
/// Fetch the articleIDs of unread articles in feeds specified by webFeedIDs.
|
||||
public func fetchUnreadArticleIDsAsync(webFeedIDs: Set<String>, callback: @escaping (Set<String>) -> Void) {
|
||||
articlesTable.fetchUnreadArticleIDsAsync(webFeedIDs, callback)
|
||||
public func fetchUnreadArticleIDsAsync(webFeedIDs: Set<String>, completion: @escaping (Set<String>) -> Void) {
|
||||
articlesTable.fetchUnreadArticleIDsAsync(webFeedIDs, completion)
|
||||
}
|
||||
|
||||
/// Fetch the articleIDs of starred articles in feeds specified by webFeedIDs.
|
||||
public func fetchStarredArticleIDsAsync(webFeedIDs: Set<String>, callback: @escaping (Set<String>) -> Void) {
|
||||
articlesTable.fetchStarredArticleIDsAsync(webFeedIDs, callback)
|
||||
public func fetchStarredArticleIDsAsync(webFeedIDs: Set<String>, completion: @escaping (Set<String>) -> Void) {
|
||||
articlesTable.fetchStarredArticleIDsAsync(webFeedIDs, completion)
|
||||
}
|
||||
|
||||
public func fetchArticleIDsForStatusesWithoutArticles() -> Set<String> {
|
||||
@ -172,8 +172,8 @@ public final class ArticlesDatabase {
|
||||
return articlesTable.mark(articles, statusKey, flag)
|
||||
}
|
||||
|
||||
public func fetchStatuses(articleIDs: Set<String>, createIfNeeded: Bool, callback: @escaping (Set<ArticleStatus>?) -> Void) {
|
||||
articlesTable.fetchStatuses(articleIDs, createIfNeeded, callback)
|
||||
public func fetchStatuses(articleIDs: Set<String>, createIfNeeded: Bool, completion: @escaping (Set<ArticleStatus>?) -> Void) {
|
||||
articlesTable.fetchStatuses(articleIDs, createIfNeeded, completion)
|
||||
}
|
||||
|
||||
// MARK: - Suspend and Resume (for iOS)
|
||||
|
@ -47,8 +47,8 @@ final class ArticlesTable: DatabaseTable {
|
||||
return fetchArticles{ self.fetchArticlesForFeedID(webFeedID, withLimits: true, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(_ webFeedID: String, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesForFeedID(webFeedID, withLimits: true, $0) }, callback)
|
||||
func fetchArticlesAsync(_ webFeedID: String, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesForFeedID(webFeedID, withLimits: true, $0) }, completion)
|
||||
}
|
||||
|
||||
private func fetchArticlesForFeedID(_ webFeedID: String, withLimits: Bool, _ database: FMDatabase) -> Set<Article> {
|
||||
@ -59,8 +59,8 @@ final class ArticlesTable: DatabaseTable {
|
||||
return fetchArticles{ self.fetchArticles(webFeedIDs, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(_ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticles(webFeedIDs, $0) }, callback)
|
||||
func fetchArticlesAsync(_ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticles(webFeedIDs, $0) }, completion)
|
||||
}
|
||||
|
||||
private func fetchArticles(_ webFeedIDs: Set<String>, _ database: FMDatabase) -> Set<Article> {
|
||||
@ -80,8 +80,8 @@ final class ArticlesTable: DatabaseTable {
|
||||
return fetchArticles{ self.fetchArticles(articleIDs: articleIDs, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(articleIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
return fetchArticlesAsync({ self.fetchArticles(articleIDs: articleIDs, $0) }, callback)
|
||||
func fetchArticlesAsync(articleIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
return fetchArticlesAsync({ self.fetchArticles(articleIDs: articleIDs, $0) }, completion)
|
||||
}
|
||||
|
||||
private func fetchArticles(articleIDs: Set<String>, _ database: FMDatabase) -> Set<Article> {
|
||||
@ -100,8 +100,8 @@ final class ArticlesTable: DatabaseTable {
|
||||
return fetchArticles{ self.fetchUnreadArticles(webFeedIDs, $0) }
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(_ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchUnreadArticles(webFeedIDs, $0) }, callback)
|
||||
func fetchUnreadArticlesAsync(_ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchUnreadArticles(webFeedIDs, $0) }, completion)
|
||||
}
|
||||
|
||||
private func fetchUnreadArticles(_ webFeedIDs: Set<String>, _ database: FMDatabase) -> Set<Article> {
|
||||
@ -121,8 +121,8 @@ final class ArticlesTable: DatabaseTable {
|
||||
return fetchArticles{ self.fetchArticlesSince(webFeedIDs, cutoffDate, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesSinceAsync(_ webFeedIDs: Set<String>, _ cutoffDate: Date, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesSince(webFeedIDs, cutoffDate, $0) }, callback)
|
||||
func fetchArticlesSinceAsync(_ webFeedIDs: Set<String>, _ cutoffDate: Date, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesSince(webFeedIDs, cutoffDate, $0) }, completion)
|
||||
}
|
||||
|
||||
private func fetchArticlesSince(_ webFeedIDs: Set<String>, _ cutoffDate: Date, _ database: FMDatabase) -> Set<Article> {
|
||||
@ -144,8 +144,8 @@ final class ArticlesTable: DatabaseTable {
|
||||
return fetchArticles{ self.fetchStarredArticles(webFeedIDs, $0) }
|
||||
}
|
||||
|
||||
func fetchStarredArticlesAsync(_ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchStarredArticles(webFeedIDs, $0) }, callback)
|
||||
func fetchStarredArticlesAsync(_ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchStarredArticles(webFeedIDs, $0) }, completion)
|
||||
}
|
||||
|
||||
private func fetchStarredArticles(_ webFeedIDs: Set<String>, _ database: FMDatabase) -> Set<Article> {
|
||||
@ -184,12 +184,12 @@ final class ArticlesTable: DatabaseTable {
|
||||
return articles
|
||||
}
|
||||
|
||||
func fetchArticlesMatchingAsync(_ searchString: String, _ webFeedIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesMatching(searchString, webFeedIDs, $0) }, callback)
|
||||
func fetchArticlesMatchingAsync(_ searchString: String, _ webFeedIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesMatching(searchString, webFeedIDs, $0) }, completion)
|
||||
}
|
||||
|
||||
func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesMatchingWithArticleIDs(searchString, articleIDs, $0) }, callback)
|
||||
func fetchArticlesMatchingWithArticleIDsAsync(_ searchString: String, _ articleIDs: Set<String>, _ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync({ self.fetchArticlesMatchingWithArticleIDs(searchString, articleIDs, $0) }, completion)
|
||||
}
|
||||
|
||||
private func fetchArticlesMatching(_ searchString: String, _ webFeedIDs: Set<String>, _ database: FMDatabase) -> Set<Article> {
|
||||
@ -311,9 +311,9 @@ final class ArticlesTable: DatabaseTable {
|
||||
}
|
||||
}
|
||||
|
||||
func fetchStatuses(_ articleIDs: Set<String>, _ createIfNeeded: Bool, _ callback: @escaping (Set<ArticleStatus>?) -> Void) {
|
||||
func fetchStatuses(_ articleIDs: Set<String>, _ createIfNeeded: Bool, _ completion: @escaping (Set<ArticleStatus>?) -> Void) {
|
||||
guard !queue.isSuspended else {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ final class ArticlesTable: DatabaseTable {
|
||||
}
|
||||
let statuses = Set(statusesDictionary.values)
|
||||
DispatchQueue.main.async {
|
||||
callback(statuses)
|
||||
completion(statuses)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -357,11 +357,11 @@ final class ArticlesTable: DatabaseTable {
|
||||
}
|
||||
}
|
||||
|
||||
func fetchUnreadCount(_ webFeedIDs: Set<String>, _ since: Date, _ callback: @escaping (Int) -> Void) {
|
||||
func fetchUnreadCount(_ webFeedIDs: Set<String>, _ since: Date, _ completion: @escaping (Int) -> Void) {
|
||||
// Get unread count for today, for instance.
|
||||
|
||||
if webFeedIDs.isEmpty || queue.isSuspended {
|
||||
callback(0)
|
||||
completion(0)
|
||||
return
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ final class ArticlesTable: DatabaseTable {
|
||||
let unreadCount = self.numberWithSQLAndParameters(sql, parameters, in: database)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
callback(unreadCount)
|
||||
completion(unreadCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -416,9 +416,9 @@ final class ArticlesTable: DatabaseTable {
|
||||
}
|
||||
}
|
||||
|
||||
func fetchStarredAndUnreadCount(_ webFeedIDs: Set<String>, _ callback: @escaping (Int) -> Void) {
|
||||
func fetchStarredAndUnreadCount(_ webFeedIDs: Set<String>, _ completion: @escaping (Int) -> Void) {
|
||||
if webFeedIDs.isEmpty || queue.isSuspended {
|
||||
callback(0)
|
||||
completion(0)
|
||||
return
|
||||
}
|
||||
|
||||
@ -430,19 +430,19 @@ final class ArticlesTable: DatabaseTable {
|
||||
let unreadCount = self.numberWithSQLAndParameters(sql, parameters, in: database)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
callback(unreadCount)
|
||||
completion(unreadCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Statuses
|
||||
|
||||
func fetchUnreadArticleIDsAsync(_ webFeedIDs: Set<String>, _ callback: @escaping (Set<String>) -> Void) {
|
||||
fetchArticleIDsAsync(.read, false, webFeedIDs, callback)
|
||||
func fetchUnreadArticleIDsAsync(_ webFeedIDs: Set<String>, _ completion: @escaping (Set<String>) -> Void) {
|
||||
fetchArticleIDsAsync(.read, false, webFeedIDs, completion)
|
||||
}
|
||||
|
||||
func fetchStarredArticleIDsAsync(_ webFeedIDs: Set<String>, _ callback: @escaping (Set<String>) -> Void) {
|
||||
fetchArticleIDsAsync(.starred, true, webFeedIDs, callback)
|
||||
func fetchStarredArticleIDsAsync(_ webFeedIDs: Set<String>, _ completion: @escaping (Set<String>) -> Void) {
|
||||
fetchArticleIDsAsync(.starred, true, webFeedIDs, completion)
|
||||
}
|
||||
|
||||
func fetchStarredArticleIDs() -> Set<String> {
|
||||
@ -541,15 +541,15 @@ private extension ArticlesTable {
|
||||
return articles
|
||||
}
|
||||
|
||||
private func fetchArticlesAsync(_ fetchMethod: @escaping ArticlesFetchMethod, _ callback: @escaping ArticleSetBlock) {
|
||||
private func fetchArticlesAsync(_ fetchMethod: @escaping ArticlesFetchMethod, _ completion: @escaping ArticleSetBlock) {
|
||||
guard !queue.isSuspended else {
|
||||
callback(Set<Article>())
|
||||
completion(Set<Article>())
|
||||
return
|
||||
}
|
||||
queue.runInDatabase { (database) in
|
||||
let articles = fetchMethod(database)
|
||||
DispatchQueue.main.async {
|
||||
callback(articles)
|
||||
completion(articles)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -702,9 +702,9 @@ private extension ArticlesTable {
|
||||
return articlesWithResultSet(resultSet, database)
|
||||
}
|
||||
|
||||
func fetchArticleIDsAsync(_ statusKey: ArticleStatus.Key, _ value: Bool, _ webFeedIDs: Set<String>, _ callback: @escaping (Set<String>) -> Void) {
|
||||
func fetchArticleIDsAsync(_ statusKey: ArticleStatus.Key, _ value: Bool, _ webFeedIDs: Set<String>, _ completion: @escaping (Set<String>) -> Void) {
|
||||
guard !queue.isSuspended && !webFeedIDs.isEmpty else {
|
||||
callback(Set<String>())
|
||||
completion(Set<String>())
|
||||
return
|
||||
}
|
||||
queue.runInDatabase { database in
|
||||
@ -720,14 +720,14 @@ private extension ArticlesTable {
|
||||
|
||||
guard let resultSet = database.executeQuery(sql, withArgumentsIn: parameters) else {
|
||||
DispatchQueue.main.async {
|
||||
callback(Set<String>())
|
||||
completion(Set<String>())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let articleIDs = resultSet.mapToSet{ $0.string(forColumnIndex: 0) }
|
||||
DispatchQueue.main.async {
|
||||
callback(articleIDs)
|
||||
completion(articleIDs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ final class DetailViewController: NSViewController, WKUIDelegate {
|
||||
currentWebViewController = webViewController(for: mode)
|
||||
}
|
||||
|
||||
func canScrollDown(_ callback: @escaping (Bool) -> Void) {
|
||||
currentWebViewController.canScrollDown(callback)
|
||||
func canScrollDown(_ completion: @escaping (Bool) -> Void) {
|
||||
currentWebViewController.canScrollDown(completion)
|
||||
}
|
||||
|
||||
override func scrollPageDown(_ sender: Any?) {
|
||||
|
@ -127,9 +127,9 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
|
||||
|
||||
// MARK: Scrolling
|
||||
|
||||
func canScrollDown(_ callback: @escaping (Bool) -> Void) {
|
||||
func canScrollDown(_ completion: @escaping (Bool) -> Void) {
|
||||
fetchScrollInfo { (scrollInfo) in
|
||||
callback(scrollInfo?.canScrollDown ?? false)
|
||||
completion(scrollInfo?.canScrollDown ?? false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ private extension DetailWebViewController {
|
||||
webView.evaluateJavaScript(render)
|
||||
}
|
||||
|
||||
func fetchScrollInfo(_ callback: @escaping (ScrollInfo?) -> Void) {
|
||||
func fetchScrollInfo(_ completion: @escaping (ScrollInfo?) -> Void) {
|
||||
var javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: document.body.scrollTop}; x"
|
||||
if #available(macOS 10.15, *) {
|
||||
javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: window.pageYOffset}; x"
|
||||
@ -235,16 +235,16 @@ private extension DetailWebViewController {
|
||||
|
||||
webView.evaluateJavaScript(javascriptString) { (info, error) in
|
||||
guard let info = info as? [String: Any] else {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
guard let contentHeight = info["contentHeight"] as? CGFloat, let offsetY = info["offsetY"] as? CGFloat else {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
let scrollInfo = ScrollInfo(contentHeight: contentHeight, viewHeight: self.webView.frame.height, offsetY: offsetY)
|
||||
callback(scrollInfo)
|
||||
completion(scrollInfo)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -595,19 +595,19 @@ private extension SidebarViewController {
|
||||
return rowView.view(atColumn: 0) as? SidebarCell
|
||||
}
|
||||
|
||||
func applyToAvailableCells(_ callback: (SidebarCell, Node) -> Void) {
|
||||
func applyToAvailableCells(_ completion: (SidebarCell, Node) -> Void) {
|
||||
outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) -> Void in
|
||||
guard let cell = cellForRowView(rowView), let node = nodeForRow(row) else {
|
||||
return
|
||||
}
|
||||
callback(cell, node)
|
||||
completion(cell, node)
|
||||
}
|
||||
}
|
||||
|
||||
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ callback: (SidebarCell, Node) -> Void) {
|
||||
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ completion: (SidebarCell, Node) -> Void) {
|
||||
applyToAvailableCells { (cell, node) in
|
||||
if node.representsSidebarObject(representedObject) {
|
||||
callback(cell, node)
|
||||
completion(cell, node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1027,7 +1027,7 @@ private extension TimelineViewController {
|
||||
return fetchedArticles
|
||||
}
|
||||
|
||||
func fetchUnsortedArticlesAsync(for representedObjects: [Any], callback: @escaping ArticleSetBlock) {
|
||||
func fetchUnsortedArticlesAsync(for representedObjects: [Any], completion: @escaping ArticleSetBlock) {
|
||||
// The callback will *not* be called if the fetch is no longer relevant — that is,
|
||||
// if it’s been superseded by a newer fetch, or the timeline was emptied, etc., it won’t get called.
|
||||
precondition(Thread.isMainThread)
|
||||
@ -1038,7 +1038,7 @@ private extension TimelineViewController {
|
||||
guard !operation.isCanceled, let strongSelf = self, operation.id == strongSelf.fetchSerialNumber else {
|
||||
return
|
||||
}
|
||||
callback(articles)
|
||||
completion(articles)
|
||||
}
|
||||
fetchRequestQueue.add(fetchOperation)
|
||||
}
|
||||
|
@ -13,15 +13,15 @@ import RSParser
|
||||
|
||||
struct FaviconURLFinder {
|
||||
|
||||
static func findFaviconURLs(_ homePageURL: String, _ callback: @escaping ([String]?) -> Void) {
|
||||
static func findFaviconURLs(_ homePageURL: String, _ completion: @escaping ([String]?) -> Void) {
|
||||
|
||||
guard let _ = URL(string: homePageURL) else {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
HTMLMetadataDownloader.downloadMetadata(for: homePageURL) { (htmlMetadata) in
|
||||
callback(htmlMetadata?.faviconLinks)
|
||||
completion(htmlMetadata?.faviconLinks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,22 +93,22 @@ private extension SingleFaviconDownloader {
|
||||
}
|
||||
}
|
||||
|
||||
func readFromDisk(_ callback: @escaping (RSImage?) -> Void) {
|
||||
func readFromDisk(_ completion: @escaping (RSImage?) -> Void) {
|
||||
|
||||
guard diskStatus != .notOnDisk else {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
queue.async {
|
||||
|
||||
if let data = self.diskCache[self.diskKey], !data.isEmpty {
|
||||
RSImage.rs_image(with: data, imageResultBlock: callback)
|
||||
RSImage.rs_image(with: data, imageResultBlock: completion)
|
||||
return
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,10 +127,10 @@ private extension SingleFaviconDownloader {
|
||||
}
|
||||
}
|
||||
|
||||
func downloadFavicon(_ callback: @escaping (RSImage?) -> Void) {
|
||||
func downloadFavicon(_ completion: @escaping (RSImage?) -> Void) {
|
||||
|
||||
guard let url = URL(string: faviconURL) else {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ private extension SingleFaviconDownloader {
|
||||
|
||||
if let data = data, !data.isEmpty, let response = response, response.statusIsOK, error == nil {
|
||||
self.saveToDisk(data)
|
||||
RSImage.rs_image(with: data, imageResultBlock: callback)
|
||||
RSImage.rs_image(with: data, imageResultBlock: completion)
|
||||
return
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ private extension SingleFaviconDownloader {
|
||||
appDelegate.logMessage("Error downloading favicon at \(url): \(error)", type: .warning)
|
||||
}
|
||||
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@ struct HTMLMetadataDownloader {
|
||||
|
||||
static let serialDispatchQueue = DispatchQueue(label: "HTMLMetadataDownloader")
|
||||
|
||||
static func downloadMetadata(for url: String, _ callback: @escaping (RSHTMLMetadata?) -> Void) {
|
||||
static func downloadMetadata(for url: String, _ completion: @escaping (RSHTMLMetadata?) -> Void) {
|
||||
guard let actualURL = URL(string: url) else {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ struct HTMLMetadataDownloader {
|
||||
if let data = data, !data.isEmpty, let response = response, response.statusIsOK, error == nil {
|
||||
let urlToUse = response.url ?? actualURL
|
||||
let parserData = ParserData(url: urlToUse.absoluteString, data: data)
|
||||
parseMetadata(with: parserData, callback)
|
||||
parseMetadata(with: parserData, completion)
|
||||
return
|
||||
}
|
||||
|
||||
@ -32,15 +32,15 @@ struct HTMLMetadataDownloader {
|
||||
appDelegate.logMessage("Error downloading metadata at \(url): \(error)", type: .warning)
|
||||
}
|
||||
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
}
|
||||
}
|
||||
|
||||
private static func parseMetadata(with parserData: ParserData, _ callback: @escaping (RSHTMLMetadata?) -> Void) {
|
||||
private static func parseMetadata(with parserData: ParserData, _ completion: @escaping (RSHTMLMetadata?) -> Void) {
|
||||
serialDispatchQueue.async {
|
||||
let htmlMetadata = RSHTMLMetadataParser.htmlMetadata(with: parserData)
|
||||
DispatchQueue.main.async {
|
||||
callback(htmlMetadata)
|
||||
completion(htmlMetadata)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,27 +76,27 @@ private extension ImageDownloader {
|
||||
}
|
||||
}
|
||||
|
||||
func readFromDisk(_ url: String, _ callback: @escaping (Data?) -> Void) {
|
||||
func readFromDisk(_ url: String, _ completion: @escaping (Data?) -> Void) {
|
||||
|
||||
queue.async {
|
||||
|
||||
if let data = self.diskCache[self.diskKey(url)], !data.isEmpty {
|
||||
DispatchQueue.main.async {
|
||||
callback(data)
|
||||
completion(data)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func downloadImage(_ url: String, _ callback: @escaping (Data?) -> Void) {
|
||||
func downloadImage(_ url: String, _ completion: @escaping (Data?) -> Void) {
|
||||
|
||||
guard let imageURL = URL(string: url) else {
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ private extension ImageDownloader {
|
||||
|
||||
if let data = data, !data.isEmpty, let response = response, response.statusIsOK, error == nil {
|
||||
self.saveToDisk(url, data)
|
||||
callback(data)
|
||||
completion(data)
|
||||
return
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ private extension ImageDownloader {
|
||||
appDelegate.logMessage("Error downloading image at \(url): \(error)", type: .warning)
|
||||
}
|
||||
|
||||
callback(nil)
|
||||
completion(nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ struct SearchFeedDelegate: SmartFeedDelegate {
|
||||
self.fetchType = .search(searchString)
|
||||
}
|
||||
|
||||
func fetchUnreadCount(for: Account, callback: @escaping (Int) -> Void) {
|
||||
func fetchUnreadCount(for: Account, completion: @escaping (Int) -> Void) {
|
||||
// TODO: after 5.0
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ struct SearchTimelineFeedDelegate: SmartFeedDelegate {
|
||||
self.fetchType = .searchWithArticleIDs(searchString, articleIDs)
|
||||
}
|
||||
|
||||
func fetchUnreadCount(for: Account, callback: @escaping (Int) -> Void) {
|
||||
func fetchUnreadCount(for: Account, completion: @escaping (Int) -> Void) {
|
||||
// TODO: after 5.0
|
||||
}
|
||||
}
|
||||
|
@ -84,16 +84,16 @@ extension SmartFeed: ArticleFetcher {
|
||||
return delegate.fetchArticles()
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
delegate.fetchArticlesAsync(callback)
|
||||
func fetchArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
delegate.fetchArticlesAsync(completion)
|
||||
}
|
||||
|
||||
func fetchUnreadArticles() -> Set<Article> {
|
||||
return delegate.fetchUnreadArticles()
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
delegate.fetchUnreadArticlesAsync(callback)
|
||||
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
delegate.fetchUnreadArticlesAsync(completion)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import RSCore
|
||||
|
||||
protocol SmartFeedDelegate: FeedIdentifiable, DisplayNameProvider, ArticleFetcher, SmallIconProvider {
|
||||
var fetchType: FetchType { get }
|
||||
func fetchUnreadCount(for: Account, callback: @escaping (Int) -> Void)
|
||||
func fetchUnreadCount(for: Account, completion: @escaping (Int) -> Void)
|
||||
}
|
||||
|
||||
extension SmartFeedDelegate {
|
||||
@ -22,15 +22,15 @@ extension SmartFeedDelegate {
|
||||
return AccountManager.shared.fetchArticles(fetchType)
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
AccountManager.shared.fetchArticlesAsync(fetchType, callback)
|
||||
func fetchArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
AccountManager.shared.fetchArticlesAsync(fetchType, completion)
|
||||
}
|
||||
|
||||
func fetchUnreadArticles() -> Set<Article> {
|
||||
return fetchArticles().unreadArticles()
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync{ callback($0.unreadArticles()) }
|
||||
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
fetchArticlesAsync{ completion($0.unreadArticles()) }
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ struct StarredFeedDelegate: SmartFeedDelegate {
|
||||
let fetchType: FetchType = .starred
|
||||
var smallIcon: IconImage? = AppAssets.starredFeedImage
|
||||
|
||||
func fetchUnreadCount(for account: Account, callback: @escaping (Int) -> Void) {
|
||||
account.fetchUnreadCountForStarredArticles(callback)
|
||||
func fetchUnreadCount(for account: Account, completion: @escaping (Int) -> Void) {
|
||||
account.fetchUnreadCountForStarredArticles(completion)
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ struct TodayFeedDelegate: SmartFeedDelegate {
|
||||
let fetchType = FetchType.today
|
||||
var smallIcon: IconImage? = AppAssets.todayFeedImage
|
||||
|
||||
func fetchUnreadCount(for account: Account, callback: @escaping (Int) -> Void) {
|
||||
account.fetchUnreadCountForToday(callback)
|
||||
func fetchUnreadCount(for account: Account, completion: @escaping (Int) -> Void) {
|
||||
account.fetchUnreadCountForToday(completion)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,15 +65,15 @@ extension UnreadFeed: ArticleFetcher {
|
||||
return fetchUnreadArticles()
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
fetchUnreadArticlesAsync(callback)
|
||||
func fetchArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
fetchUnreadArticlesAsync(completion)
|
||||
}
|
||||
|
||||
func fetchUnreadArticles() -> Set<Article> {
|
||||
return AccountManager.shared.fetchArticles(fetchType)
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(_ callback: @escaping ArticleSetBlock) {
|
||||
AccountManager.shared.fetchArticlesAsync(fetchType, callback)
|
||||
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock) {
|
||||
AccountManager.shared.fetchArticlesAsync(fetchType, completion)
|
||||
}
|
||||
}
|
||||
|
@ -764,20 +764,20 @@ private extension MasterFeedViewController {
|
||||
applyToCellsForRepresentedObject(representedObject, configure)
|
||||
}
|
||||
|
||||
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ callback: (MasterFeedTableViewCell, Node) -> Void) {
|
||||
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ completion: (MasterFeedTableViewCell, Node) -> Void) {
|
||||
applyToAvailableCells { (cell, node) in
|
||||
if node.representedObject === representedObject {
|
||||
callback(cell, node)
|
||||
completion(cell, node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func applyToAvailableCells(_ callback: (MasterFeedTableViewCell, Node) -> Void) {
|
||||
func applyToAvailableCells(_ completion: (MasterFeedTableViewCell, Node) -> Void) {
|
||||
tableView.visibleCells.forEach { cell in
|
||||
guard let indexPath = tableView.indexPath(for: cell), let node = dataSource.itemIdentifier(for: indexPath) else {
|
||||
return
|
||||
}
|
||||
callback(cell as! MasterFeedTableViewCell, node)
|
||||
completion(cell as! MasterFeedTableViewCell, node)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1630,7 +1630,7 @@ private extension SceneCoordinator {
|
||||
|
||||
}
|
||||
|
||||
func fetchUnsortedArticlesAsync(for representedObjects: [Any], callback: @escaping ArticleSetBlock) {
|
||||
func fetchUnsortedArticlesAsync(for representedObjects: [Any], completion: @escaping ArticleSetBlock) {
|
||||
// The callback will *not* be called if the fetch is no longer relevant — that is,
|
||||
// if it’s been superseded by a newer fetch, or the timeline was emptied, etc., it won’t get called.
|
||||
precondition(Thread.isMainThread)
|
||||
@ -1641,7 +1641,7 @@ private extension SceneCoordinator {
|
||||
guard !operation.isCanceled, let strongSelf = self, operation.id == strongSelf.fetchSerialNumber else {
|
||||
return
|
||||
}
|
||||
callback(articles)
|
||||
completion(articles)
|
||||
}
|
||||
|
||||
fetchRequestQueue.add(fetchOperation)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b2ad9272e8003b0aba3c8c961239663ac501f00b
|
||||
Subproject commit 8a574c7dc24156d9d01c6c9fe7d4c9e099c54a96
|
@ -1 +1 @@
|
||||
Subproject commit 81c400a7665309a08414bf43ca5161d90d072501
|
||||
Subproject commit 9e5f5d644c1291daf516b9466cb23592374f8e10
|
@ -1 +1 @@
|
||||
Subproject commit b2dd50f1ff2a64c09a543d00bc35c8a66c1fc2b6
|
||||
Subproject commit e513062972cd8097179ed39999f327ad29c8a4e1
|
Loading…
Reference in New Issue
Block a user