Merge branch 'main' into localize_strings

# Conflicts:
#	Shared/Timer/AccountRefreshTimer.swift
This commit is contained in:
Stuart Breckenridge
2023-01-04 15:17:14 +08:00
22 changed files with 593 additions and 142 deletions

View File

@@ -35,5 +35,10 @@ struct SearchFeedDelegate: SmartFeedDelegate {
func fetchUnreadCount(for: Account, completion: @escaping SingleUnreadCountCompletionBlock) {
// TODO: after 5.0
}
func fetchUnreadArticlesBetween(before: Date? = nil, after: Date? = nil) throws -> Set<Article> {
fatalError("Function not implemented.")
}
}

View File

@@ -35,4 +35,9 @@ struct SearchTimelineFeedDelegate: SmartFeedDelegate {
func fetchUnreadCount(for: Account, completion: @escaping SingleUnreadCountCompletionBlock) {
// TODO: after 5.0
}
func fetchUnreadArticlesBetween(before: Date? = nil, after: Date? = nil) throws -> Set<Article> {
fatalError("Function not implemented.")
}
}

View File

@@ -46,7 +46,7 @@ final class SmartFeed: PseudoFeed {
}
#endif
private let delegate: SmartFeedDelegate
public let delegate: SmartFeedDelegate
private var unreadCounts = [String: Int]()
init(delegate: SmartFeedDelegate) {
@@ -95,6 +95,10 @@ extension SmartFeed: ArticleFetcher {
return try delegate.fetchUnreadArticles()
}
func fetchUnreadArticlesBetween(before: Date? = nil, after: Date? = nil) throws -> Set<Article> {
return try delegate.fetchUnreadArticlesBetween(before: before, after: after)
}
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
delegate.fetchUnreadArticlesAsync(completion)
}

View File

@@ -31,6 +31,10 @@ extension SmartFeedDelegate {
return try fetchArticles().unreadArticles()
}
func fetchUnreadArticlesBetween(before: Date? = nil, after: Date? = nil) throws -> Set<Article> {
return try AccountManager.shared.fetchUnreadArticlesBetween(limit: nil, before: before, after: after)
}
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
fetchArticlesAsync{ articleSetResult in
switch articleSetResult {

View File

@@ -29,4 +29,8 @@ struct StarredFeedDelegate: SmartFeedDelegate {
func fetchUnreadCount(for account: Account, completion: @escaping SingleUnreadCountCompletionBlock) {
account.fetchUnreadCountForStarredArticles(completion)
}
func fetchUnreadArticlesBetween(before: Date? = nil, after: Date? = nil) throws -> Set<Article> {
return try AccountManager.shared.fetchUnreadArticlesBetween(limit: nil, before: before, after: after).filter({ $0.status.starred })
}
}

View File

@@ -78,6 +78,10 @@ extension UnreadFeed: ArticleFetcher {
return try AccountManager.shared.fetchArticles(fetchType)
}
func fetchUnreadArticlesBetween(before: Date? = nil, after: Date? = nil) throws -> Set<Article> {
return try AccountManager.shared.fetchUnreadArticlesBetween(limit: nil, before: before, after: after)
}
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
AccountManager.shared.fetchArticlesAsync(fetchType, completion)
}

View File

@@ -73,8 +73,7 @@ class AccountRefreshTimer {
lastTimedRefresh = Date()
update()
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.log, completion: nil)
AccountManager.shared.refreshAll(errorHandler: ErrorHandler.log)
}
}