Update Feedbin to use fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate for missing articles.

This commit is contained in:
Maurice Parker 2019-12-17 17:43:08 -07:00
parent 2148bb29dc
commit 236f581d95
3 changed files with 45 additions and 36 deletions

View File

@ -689,10 +689,16 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
database.fetchStarredArticleIDsAsync(webFeedIDs: flattenedWebFeeds().webFeedIDs(), completion: completion)
}
/// Deprecated. Use fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate instead.
public func fetchArticleIDsForStatusesWithoutArticles() throws -> Set<String> {
return try database.fetchArticleIDsForStatusesWithoutArticles()
}
/// Fetch articleIDs for articles that we should have, but dont. These articles are not userDeleted, and they are either (starred) or (unread and newer than the article cutoff date).
public func fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(_ completion: @escaping ArticleIDsCompletionBlock) {
database.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(completion)
}
public func unreadCount(for webFeed: WebFeed) -> Int {
return unreadCounts[webFeed.webFeedID] ?? 0
}

View File

@ -1127,18 +1127,14 @@ private extension FeedbinAccountDelegate {
func refreshMissingArticles(_ account: Account, completion: @escaping ((Result<Void, Error>) -> Void)) {
os_log(.debug, log: log, "Refreshing missing articles...")
account.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate { result in
switch result {
case .success(let fetchedArticleIDs):
let group = DispatchGroup()
var errorOccurred = false
var fetchedArticleIDs = Set<String>()
do {
fetchedArticleIDs = try account.fetchArticleIDsForStatusesWithoutArticles()
}
catch(let error) {
self.refreshProgress.completeTask()
completion(.failure(error))
return
}
let articleIDs = Array(fetchedArticleIDs)
let chunkedArticleIDs = articleIDs.chunked(into: 100)
@ -1174,6 +1170,13 @@ private extension FeedbinAccountDelegate {
completion(.success(()))
}
}
case .failure(let error):
completion(.failure(error))
}
}
}
func refreshArticles(_ account: Account, page: String?, updateFetchDate: Date?, completion: @escaping ((Result<Void, Error>) -> Void)) {

View File

@ -182,7 +182,7 @@ public final class ArticlesDatabase {
}
/// Fetch articleIDs for articles that we should have, but dont. These articles are not userDeleted, and they are either (starred) or (unread and newer than the article cutoff date).
func fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(_ completion: @escaping ArticleIDsCompletionBlock) {
public func fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(_ completion: @escaping ArticleIDsCompletionBlock) {
articlesTable.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate(completion)
}