mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Continue adopting async/await.
This commit is contained in:
@@ -946,6 +946,14 @@ public enum FetchType {
|
||||
mark(articleIDs: articleIDs, statusKey: .starred, flag: false, completion: completion)
|
||||
}
|
||||
|
||||
// Delete the articles associated with the given set of articleIDs
|
||||
func deleteArticleIDs(_ articleIDs: Set<String>) async throws {
|
||||
guard !articleIDs.isEmpty else {
|
||||
return
|
||||
}
|
||||
try await database.deleteArticleIDs(articleIDs)
|
||||
}
|
||||
|
||||
// Delete the articles associated with the given set of articleIDs
|
||||
func delete(articleIDs: Set<String>, completion: DatabaseCompletionBlock? = nil) {
|
||||
guard !articleIDs.isEmpty else {
|
||||
|
||||
@@ -74,22 +74,22 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
database.deleteSelectedForProcessing(Array(deletableArticleIDs)) { databaseError in
|
||||
database.deleteSelectedForProcessing(Array(deletableArticleIDs)) { databaseError in
|
||||
Task { @MainActor in
|
||||
if let databaseError = databaseError {
|
||||
completion(databaseError)
|
||||
} else {
|
||||
self.account?.delete(articleIDs: deletableArticleIDs) { databaseError in
|
||||
if let databaseError = databaseError {
|
||||
completion(databaseError)
|
||||
} else {
|
||||
completion(nil)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
try await self.account?.deleteArticleIDs(deletableArticleIDs)
|
||||
completion(nil)
|
||||
} catch let error {
|
||||
completion(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor func update(records: [CKRecord], pendingReadStatusArticleIDs: Set<String>, pendingStarredStatusArticleIDs: Set<String>, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
|
||||
|
||||
@@ -231,6 +231,11 @@ public typealias ArticleStatusesResultBlock = (ArticleStatusesResult) -> Void
|
||||
articlesTable.update(feedIDsAndItems, defaultRead, completion)
|
||||
}
|
||||
|
||||
/// Delete articles
|
||||
public func deleteArticleIDs(_ articleIDs: Set<String>) async throws {
|
||||
try await articlesTable.deleteArticleIDs(articleIDs)
|
||||
}
|
||||
|
||||
/// Delete articles
|
||||
public func delete(articleIDs: Set<String>, completion: DatabaseCompletionBlock?) {
|
||||
articlesTable.delete(articleIDs: articleIDs, completion: completion)
|
||||
|
||||
@@ -367,6 +367,23 @@ final class ArticlesTable: DatabaseTable {
|
||||
}
|
||||
}
|
||||
|
||||
public func deleteArticleIDs(_ articleIDs: Set<String>) async throws {
|
||||
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
Task { @MainActor in
|
||||
queue.runInTransaction { databaseResult in
|
||||
switch databaseResult {
|
||||
case .success(let database):
|
||||
self.removeArticles(articleIDs, database)
|
||||
continuation.resume()
|
||||
case .failure(let databaseError):
|
||||
continuation.resume(throwing: databaseError)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func delete(articleIDs: Set<String>, completion: DatabaseCompletionBlock?) {
|
||||
self.queue.runInTransaction { (databaseResult) in
|
||||
|
||||
|
||||
Reference in New Issue
Block a user