Skip to content

Commit

Permalink
Allow permanently deleting locally trashed drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed May 20, 2024
1 parent 2f0f965 commit 6b93f89
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion WordPress/Classes/Services/PostRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,18 @@ final class PostRepository {
func _delete(_ post: AbstractPost) async throws {
wpAssert(post.isOriginal())

let context = coreDataStack.mainContext
guard let postID = post.postID, postID.intValue > 0 else {
// The new sync system makes this situation impossible, but there
// might exist posts from the previous versions of the app in this state.
post.deleteAllRevisions()
context.deleteObject(post)
ContextManager.shared.saveContextAndWait(context)

return wpAssertionFailure("Trying to patch a non-existent post")
}
try await getRemoteService(for: post.blog).deletePost(withID: postID.intValue)

let context = coreDataStack.mainContext
context.deleteObject(post)
ContextManager.shared.saveContextAndWait(context)
}
Expand Down

0 comments on commit 6b93f89

Please sign in to comment.