From 31d0b9d3e4570bc9ea99fdb2ae22095045052b11 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 10 Jun 2026 14:55:44 -0700 Subject: [PATCH] Continue post-DatabaseResult simplification. --- Modules/Account/Sources/Account/Account.swift | 46 +++++++++---------- .../ArticlesDatabase/ArticlesDatabase.swift | 24 +++++----- .../ArticlesDatabase/ArticlesTable.swift | 26 +++++------ 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift index fb206365f..5a9f6da35 100644 --- a/Modules/Account/Sources/Account/Account.swift +++ b/Modules/Account/Sources/Account/Account.swift @@ -815,21 +815,21 @@ public enum FetchType { public func fetchArticles(_ fetchType: FetchType) throws -> Set
{ switch fetchType { case .starred(let limit): - return try _fetchStarredArticles(limit: limit) + return _fetchStarredArticles(limit: limit) case .unread(let limit): - return try _fetchUnreadArticles(limit: limit) + return _fetchUnreadArticles(limit: limit) case .today(let limit): - return try _fetchTodayArticles(limit: limit) + return _fetchTodayArticles(limit: limit) case .folder(let folder, let readFilter): if readFilter { - return try _fetchUnreadArticles(container: folder) + return _fetchUnreadArticles(container: folder) } else { - return try _fetchArticles(container: folder) + return _fetchArticles(container: folder) } case .feed(let feed): - return try _fetchArticles(feed: feed) + return _fetchArticles(feed: feed) case .articleIDs(let articleIDs): - return try _fetchArticles(articleIDs: articleIDs) + return _fetchArticles(articleIDs: articleIDs) case .search(let searchString): return try _fetchArticlesMatching(searchString: searchString) case .searchWithArticleIDs(let searchString, let articleIDs): @@ -1203,8 +1203,8 @@ private extension Account { // MARK: - Starred Articles - func _fetchStarredArticles(limit: Int? = nil) throws -> Set
{ - try database.fetchStarredArticles(feedIDs: flattenedFeedsIDs, limit: limit) + func _fetchStarredArticles(limit: Int? = nil) -> Set
{ + database.fetchStarredArticles(feedIDs: flattenedFeedsIDs, limit: limit) } func _fetchStarredArticlesAsync(limit: Int? = nil) async throws -> Set
{ @@ -1213,8 +1213,8 @@ private extension Account { // MARK: - Account Unread Articles - func _fetchUnreadArticles(limit: Int? = nil) throws -> Set
{ - try _fetchUnreadArticles(container: self, limit: limit) + func _fetchUnreadArticles(limit: Int? = nil) -> Set
{ + _fetchUnreadArticles(container: self, limit: limit) } func _fetchUnreadArticlesAsync(limit: Int? = nil) async throws -> Set
{ @@ -1223,8 +1223,8 @@ private extension Account { // MARK: - Today Articles - func _fetchTodayArticles(limit: Int? = nil) throws -> Set
{ - try database.fetchTodayArticles(feedIDs: flattenedFeedsIDs, limit: limit) + func _fetchTodayArticles(limit: Int? = nil) -> Set
{ + database.fetchTodayArticles(feedIDs: flattenedFeedsIDs, limit: limit) } func _fetchTodayArticlesAsync(limit: Int? = nil) async throws -> Set
{ @@ -1233,9 +1233,9 @@ private extension Account { // MARK: - Container Articles - func _fetchArticles(container: Container) throws -> Set
{ + func _fetchArticles(container: Container) -> Set
{ let feeds = container.flattenedFeeds() - let articles = try database.fetchArticles(feedIDs: feeds.feedIDs()) + let articles = database.fetchArticles(feedIDs: feeds.feedIDs()) validateUnreadCountsAfterFetchingUnreadArticles(feeds: feeds, articles: articles) return articles } @@ -1247,9 +1247,9 @@ private extension Account { return articles } - func _fetchUnreadArticles(container: Container, limit: Int? = nil) throws -> Set
{ + func _fetchUnreadArticles(container: Container, limit: Int? = nil) -> Set
{ let feeds = container.flattenedFeeds() - let articles = try database.fetchUnreadArticles(feedIDs: feeds.feedIDs(), limit: limit) + let articles = database.fetchUnreadArticles(feedIDs: feeds.feedIDs(), limit: limit) // We don't validate limit queries because they, by definition, won't correctly match the // complete unread state for the given container. @@ -1275,8 +1275,8 @@ private extension Account { // MARK: - Feed Articles - func _fetchArticles(feed: Feed) throws -> Set
{ - let articles = try database.fetchArticles(feedID: feed.feedID) + func _fetchArticles(feed: Feed) -> Set
{ + let articles = database.fetchArticles(feedID: feed.feedID) validateUnreadCount(feed: feed, articles: articles) return articles } @@ -1287,16 +1287,16 @@ private extension Account { return articles } - func _fetchUnreadArticles(feed: Feed) throws -> Set
{ - let articles = try database.fetchUnreadArticles(feedIDs: Set([feed.feedID])) + func _fetchUnreadArticles(feed: Feed) -> Set
{ + let articles = database.fetchUnreadArticles(feedIDs: Set([feed.feedID])) validateUnreadCount(feed: feed, articles: articles) return articles } // MARK: - ArticleIDs Articles - func _fetchArticles(articleIDs: Set) throws -> Set
{ - try database.fetchArticles(articleIDs: articleIDs) + func _fetchArticles(articleIDs: Set) -> Set
{ + database.fetchArticles(articleIDs: articleIDs) } func _fetchArticlesAsync(articleIDs: Set) async throws -> Set
{ diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift index 297665a80..d5839b2a8 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift @@ -108,34 +108,34 @@ public struct ArticleCounts: Sendable { // MARK: - Fetching Articles - public func fetchArticles(feedID: String) throws -> Set
{ + public func fetchArticles(feedID: String) -> Set
{ Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)") - return try articlesTable.fetchArticles(feedID) + return articlesTable.fetchArticles(feedID) } - public func fetchArticles(feedIDs: Set) throws -> Set
{ + public func fetchArticles(feedIDs: Set) -> Set
{ Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)") - return try articlesTable.fetchArticles(feedIDs) + return articlesTable.fetchArticles(feedIDs) } - public func fetchArticles(articleIDs: Set) throws -> Set
{ + public func fetchArticles(articleIDs: Set) -> Set
{ Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)") - return try articlesTable.fetchArticles(articleIDs: articleIDs) + return articlesTable.fetchArticles(articleIDs: articleIDs) } - public func fetchUnreadArticles(feedIDs: Set, limit: Int? = nil) throws -> Set
{ + public func fetchUnreadArticles(feedIDs: Set, limit: Int? = nil) -> Set
{ Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)") - return try articlesTable.fetchUnreadArticles(feedIDs, limit) + return articlesTable.fetchUnreadArticles(feedIDs, limit) } - public func fetchTodayArticles(feedIDs: Set, limit: Int? = nil) throws -> Set
{ + public func fetchTodayArticles(feedIDs: Set, limit: Int? = nil) -> Set
{ Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)") - return try articlesTable.fetchArticlesSince(feedIDs, todayCutoffDate(), limit) + return articlesTable.fetchArticlesSince(feedIDs, todayCutoffDate(), limit) } - public func fetchStarredArticles(feedIDs: Set, limit: Int? = nil) throws -> Set
{ + public func fetchStarredArticles(feedIDs: Set, limit: Int? = nil) -> Set
{ Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)") - return try articlesTable.fetchStarredArticles(feedIDs, limit) + return articlesTable.fetchStarredArticles(feedIDs, limit) } public func fetchStarredArticlesCount(feedIDs: Set) throws -> Int { diff --git a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift index 5ace3e015..8085d534c 100644 --- a/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift +++ b/Modules/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesTable.swift @@ -48,16 +48,16 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Articles for Feed - func fetchArticles(_ feedID: String) throws -> Set
{ - return try fetchArticles { self.fetchArticlesForFeedID(feedID, $0) } + func fetchArticles(_ feedID: String) -> Set
{ + fetchArticles { self.fetchArticlesForFeedID(feedID, $0) } } func fetchArticlesAsync(_ feedID: String, _ completion: @escaping ArticleSetResultBlock) { fetchArticlesAsync({ self.fetchArticlesForFeedID(feedID, $0) }, completion) } - func fetchArticles(_ feedIDs: Set) throws -> Set
{ - return try fetchArticles { self.fetchArticles(feedIDs, $0) } + func fetchArticles(_ feedIDs: Set) -> Set
{ + fetchArticles { self.fetchArticles(feedIDs, $0) } } func fetchArticlesAsync(_ feedIDs: Set, _ completion: @escaping ArticleSetResultBlock) { @@ -66,8 +66,8 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Articles by articleID - func fetchArticles(articleIDs: Set) throws -> Set
{ - return try fetchArticles { self.fetchArticles(articleIDs: articleIDs, $0) } + func fetchArticles(articleIDs: Set) -> Set
{ + fetchArticles { self.fetchArticles(articleIDs: articleIDs, $0) } } func fetchArticlesAsync(articleIDs: Set, _ completion: @escaping ArticleSetResultBlock) { @@ -76,8 +76,8 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Unread Articles - func fetchUnreadArticles(_ feedIDs: Set, _ limit: Int?) throws -> Set
{ - return try fetchArticles { self.fetchUnreadArticles(feedIDs, limit, $0) } + func fetchUnreadArticles(_ feedIDs: Set, _ limit: Int?) -> Set
{ + fetchArticles { self.fetchUnreadArticles(feedIDs, limit, $0) } } func fetchUnreadArticlesAsync(_ feedIDs: Set, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) { @@ -86,8 +86,8 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Today Articles - func fetchArticlesSince(_ feedIDs: Set, _ cutoffDate: Date, _ limit: Int?) throws -> Set
{ - return try fetchArticles { self.fetchArticlesSince(feedIDs, cutoffDate, limit, $0) } + func fetchArticlesSince(_ feedIDs: Set, _ cutoffDate: Date, _ limit: Int?) -> Set
{ + fetchArticles { self.fetchArticlesSince(feedIDs, cutoffDate, limit, $0) } } func fetchArticlesSinceAsync(_ feedIDs: Set, _ cutoffDate: Date, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) { @@ -96,8 +96,8 @@ final class ArticlesTable: DatabaseTable, Sendable { // MARK: - Fetching Starred Articles - func fetchStarredArticles(_ feedIDs: Set, _ limit: Int?) throws -> Set
{ - return try fetchArticles { self.fetchStarredArticles(feedIDs, limit, $0) } + func fetchStarredArticles(_ feedIDs: Set, _ limit: Int?) -> Set
{ + fetchArticles { self.fetchStarredArticles(feedIDs, limit, $0) } } func fetchStarredArticlesAsync(_ feedIDs: Set, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) { @@ -625,7 +625,7 @@ nonisolated private extension ArticlesTable { // MARK: - Fetching - private func fetchArticles(_ fetchMethod: @escaping ArticlesFetchMethod) throws -> Set
{ + private func fetchArticles(_ fetchMethod: @escaping ArticlesFetchMethod) -> Set
{ nonisolated(unsafe) var articles = Set
() queue.runInDatabaseSync { database in