Convert completion-based delete method to async await.

This commit is contained in:
Brent Simmons 2024-04-03 22:06:08 -07:00
parent f0634d7ab0
commit 0607b55258
3 changed files with 3 additions and 19 deletions

View File

@ -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.

View File

@ -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)
}
}

View File

@ -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.