mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Continue converting ArticlesDatabase to async/await.
This commit is contained in:
@@ -249,8 +249,8 @@ public typealias ArticleStatusesResultBlock = (ArticleStatusesResult) -> Void
|
||||
|
||||
/// 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<String>, completion: @escaping DatabaseCompletionBlock) {
|
||||
articlesTable.createStatusesIfNeeded(articleIDs, completion)
|
||||
public func createStatusesIfNeeded(articleIDs: Set<String>) async throws {
|
||||
try await articlesTable.createStatusesIfNeeded(articleIDs)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
@@ -590,17 +590,16 @@ final class ArticlesTable: DatabaseTable {
|
||||
}
|
||||
}
|
||||
|
||||
func createStatusesIfNeeded(_ articleIDs: Set<String>, _ completion: @escaping DatabaseCompletionBlock) {
|
||||
queue.runInTransaction { databaseResult in
|
||||
switch databaseResult {
|
||||
case .success(let database):
|
||||
let _ = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, true, database)
|
||||
DispatchQueue.main.async {
|
||||
completion(nil)
|
||||
}
|
||||
case .failure(let databaseError):
|
||||
DispatchQueue.main.async {
|
||||
completion(databaseError)
|
||||
func createStatusesIfNeeded(_ articleIDs: Set<String>) async throws {
|
||||
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
queue.runInTransaction { databaseResult in
|
||||
switch databaseResult {
|
||||
case .success(let database):
|
||||
let _ = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, true, database)
|
||||
continuation.resume(returning: nil)
|
||||
case .failure(let databaseError):
|
||||
continuation.resume(throwing: databaseError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user