From ec9ba9555d67f8356bbc6fe85f033e65e429893f Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Thu, 4 Dec 2025 20:32:18 -0800 Subject: [PATCH] Add method for fetching a single article (for state restoration). --- .../Account/Sources/Account/AccountManager.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Modules/Account/Sources/Account/AccountManager.swift b/Modules/Account/Sources/Account/AccountManager.swift index 7742a623b..5a19c7d77 100644 --- a/Modules/Account/Sources/Account/AccountManager.swift +++ b/Modules/Account/Sources/Account/AccountManager.swift @@ -390,6 +390,22 @@ import RSDatabase return allFetchedArticles } + /// Fetch a single article (synchronously) by accountID and articleID. + public func fetchArticle(accountID: String, articleID: String) -> Article? { + precondition(Thread.isMainThread) + + guard let account = existingAccount(accountID: accountID) else { + return nil + } + + do { + let articles = try account.fetchArticles(.articleIDs(Set([articleID]))) + return articles.first + } catch { + return nil + } + } + // MARK: - Fetching Article Counts @MainActor public func fetchCountForStarredArticles() throws -> Int {