diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index 76a6a9206..12dee3eaf 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -699,6 +699,10 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, database.fetchStarredAndUnreadCount(for: flattenedWebFeeds().webFeedIDs(), completion: completion) } + public func fetchCountForStarredArticles() throws -> Int { + return try database.fetchStarredArticlesCount(flattenedWebFeeds().webFeedIDs()) + } + public func fetchUnreadArticleIDs(_ completion: @escaping ArticleIDsCompletionBlock) { database.fetchUnreadArticleIDsAsync(completion: completion) } diff --git a/Account/Sources/Account/AccountManager.swift b/Account/Sources/Account/AccountManager.swift index 351a3479e..8982ea690 100644 --- a/Account/Sources/Account/AccountManager.swift +++ b/Account/Sources/Account/AccountManager.swift @@ -405,6 +405,17 @@ public final class AccountManager: UnreadCountProvider { } } + // MARK: - Fetching Article Counts + + public func fetchCountForStarredArticles() throws -> Int { + precondition(Thread.isMainThread) + var count = 0 + for account in activeAccounts { + count += try account.fetchCountForStarredArticles() + } + return count + } + // MARK: - Caches /// Empty caches that can reasonably be emptied — when the app moves to the background, for instance.