From 6c33ccbcebbbca443b20dd1587647026cdcca2b2 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 24 Sep 2023 11:58:29 -0700 Subject: [PATCH] Delete fetchArticlesAsync method with completion handler in favor of async/await articlesForFeed method. --- Account/Sources/Account/Account.swift | 17 +++++++---------- .../ArticlesDatabase/ArticlesDatabase.swift | 4 ---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index 8e9377346..4837b3478 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -1178,16 +1178,13 @@ private extension Account { } func fetchArticlesAsync(feed: Feed, _ completion: @escaping ArticleSetResultBlock) { - database.fetchArticlesAsync(feed.feedID) { [weak self] articleSetResult in - Task { @MainActor [weak self] in - switch articleSetResult { - case .success(let articles): - self?.validateUnreadCount(feed, articles) - completion(.success(articles)) - case .failure(let databaseError): - completion(.failure(databaseError)) - } - } + Task { @MainActor in + do { + let articles = try await self.articlesForFeed(feed) + completion(.success(articles)) + } catch { + completion(.failure(error as! DatabaseError)) + } } } diff --git a/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift b/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift index 44dd39272..fc190675d 100644 --- a/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift +++ b/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift @@ -140,10 +140,6 @@ public typealias ArticleStatusesResultBlock = (ArticleStatusesResult) -> Void try await articlesTable.articlesForFeed(feedID) } - public func fetchArticlesAsync(_ feedID: String, _ completion: @escaping ArticleSetResultBlock) { - articlesTable.fetchArticlesAsync(feedID, completion) - } - public func fetchArticlesAsync(_ feedIDs: Set, _ completion: @escaping ArticleSetResultBlock) { articlesTable.fetchArticlesAsync(feedIDs, completion) }