diff --git a/WordPress/Classes/Services/CommentService.h b/WordPress/Classes/Services/CommentService.h index ff84f9ce9717..970b7eb5ef95 100644 --- a/WordPress/Classes/Services/CommentService.h +++ b/WordPress/Classes/Services/CommentService.h @@ -32,7 +32,7 @@ extern NSUInteger const WPTopLevelHierarchicalCommentsPerPage; - (instancetype)init NS_UNAVAILABLE; // Create reply -- (void)createReplyForComment:(Comment *)comment content:(NSString *)content completion:(void (^)(Comment *reply))completion; +- (void)createReplyForComment:(Comment *)comment content:(NSString *)content completion:(void (^)(Comment * _Nullable reply))completion; // Sync comments - (void)syncCommentsForBlog:(Blog *)blog diff --git a/WordPress/Classes/Services/CommentService.m b/WordPress/Classes/Services/CommentService.m index dca4f0f8e765..8adde1b3822c 100644 --- a/WordPress/Classes/Services/CommentService.m +++ b/WordPress/Classes/Services/CommentService.m @@ -100,7 +100,7 @@ - (Comment *)createCommentForBlog:(Blog *)blog } // Create reply -- (void)createReplyForComment:(Comment *)comment content:(NSString *)content completion:(void (^)(Comment *reply))completion +- (void)createReplyForComment:(Comment *)comment content:(NSString *)content completion:(void (^)(Comment * _Nullable reply))completion { NSManagedObjectID *parentCommentID = comment.objectID; NSManagedObjectID * __block replyID = nil; diff --git a/WordPress/Classes/ViewRelated/Comments/Controllers/CommentDetailViewController.swift b/WordPress/Classes/ViewRelated/Comments/Controllers/CommentDetailViewController.swift index e6b0e0eef0bc..4babcbad0484 100644 --- a/WordPress/Classes/ViewRelated/Comments/Controllers/CommentDetailViewController.swift +++ b/WordPress/Classes/ViewRelated/Comments/Controllers/CommentDetailViewController.swift @@ -1011,8 +1011,13 @@ private extension CommentDetailViewController { return } - try await withUnsafeThrowingContinuation { continuation in + try await withUnsafeThrowingContinuation { (continuation: UnsafeContinuation) in commentService.createReply(for: comment, content: content) { reply in + guard let reply else { + DDLogError("Failed creating comment reply: reply was nil after save") + continuation.resume(throwing: URLError(.unknown)) + return + } self.commentService.uploadComment(reply, success: { [weak self] in self?.refreshCommentReplyIfNeeded() continuation.resume()