Convert completion-based delete method to async await.
This commit is contained in:
parent
f0634d7ab0
commit
0607b55258
@ -941,12 +941,11 @@ public enum FetchType {
|
||||
}
|
||||
|
||||
// Delete the articles associated with the given set of articleIDs
|
||||
func delete(articleIDs: Set<String>, completion: DatabaseCompletionBlock? = nil) {
|
||||
func delete(articleIDs: Set<String>) async throws {
|
||||
guard !articleIDs.isEmpty else {
|
||||
completion?(nil)
|
||||
return
|
||||
}
|
||||
database.delete(articleIDs: articleIDs, completion: completion)
|
||||
try await database.delete(articleIDs: articleIDs)
|
||||
}
|
||||
|
||||
/// Empty caches that can reasonably be emptied. Call when the app goes in the background, for instance.
|
||||
|
@ -71,9 +71,7 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
|
||||
Task { @MainActor in
|
||||
try? await self.database.deleteSelectedForProcessing(Array(deletableArticleIDs))
|
||||
self.account?.delete(articleIDs: deletableArticleIDs) { _ in
|
||||
completion()
|
||||
}
|
||||
try? await self.account?.delete(articleIDs: deletableArticleIDs)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,19 +56,6 @@ public extension ArticlesDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
/// Delete articles
|
||||
nonisolated func delete(articleIDs: Set<String>, completion: DatabaseCompletionBlock?) {
|
||||
|
||||
Task {
|
||||
do {
|
||||
try await delete(articleIDs: articleIDs)
|
||||
callDatabaseCompletion(completion)
|
||||
} catch {
|
||||
callDatabaseCompletion(completion, .suspended)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Status
|
||||
|
||||
/// Fetch the articleIDs of unread articles.
|
||||
|
Loading…
x
Reference in New Issue
Block a user