From fd6b6b122770bd8d2b421e5fabdef63861842eda Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 4 Oct 2023 21:14:47 -0700 Subject: [PATCH] Continue converting ArticlesDatabase to async/await. --- Account/Sources/Account/Account.swift | 10 ++++++---- .../Sources/ArticlesDatabase/ArticlesDatabase.swift | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index 59f187039..45427ae55 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -911,12 +911,14 @@ public enum FetchType { completion?(nil) return } - database.mark(articleIDs: articleIDs, statusKey: statusKey, flag: flag) { databaseError in - if let databaseError = databaseError { - completion?(databaseError) - } else { + + Task { @MainActor in + do { + try await database.markArticleIDs(articleIDs, statusKey: statusKey, flag: flag) self.noteStatusesForArticleIDsDidChange(articleIDs: articleIDs, statusKey: statusKey, flag: flag) completion?(nil) + } catch { + completion?(error as? DatabaseError) } } } diff --git a/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift b/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift index 0194295f0..409f2088b 100644 --- a/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift +++ b/ArticlesDatabase/Sources/ArticlesDatabase/ArticlesDatabase.swift @@ -247,10 +247,6 @@ public typealias ArticleStatusesResultBlock = (ArticleStatusesResult) -> Void try await articlesTable.markArticleIDs(articleIDs, statusKey, flag) } - public func mark(articleIDs: Set, statusKey: ArticleStatus.Key, flag: Bool, completion: DatabaseCompletionBlock?) { - articlesTable.mark(articleIDs, statusKey, flag, completion) - } - /// Create statuses for specified articleIDs. For existing statuses, don’t do anything. /// For newly-created statuses, mark them as read and not-starred. public func createStatusesIfNeeded(articleIDs: Set, completion: @escaping DatabaseCompletionBlock) {