From 7b38129792f28d90d6513454e3ea46590ce512f3 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 4 Dec 2024 16:43:36 -0800 Subject: [PATCH] Bring in code from previous iOS release. --- Account/Sources/Account/Account.swift | 4 ++++ Account/Sources/Account/AccountManager.swift | 11 +++++++++++ 2 files changed, 15 insertions(+) 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.