File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
WordPress/Classes/Services Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -429,7 +429,19 @@ - (void)uploadComment:(Comment *)comment
429429 } else {
430430 [remote createComment: remoteComment
431431 success: successBlock
432- failure: failure];
432+ failure: ^(NSError *error) {
433+ // When the site fails to create a comment, we need to delete the comment in the local database.
434+ [self .coreDataStack performAndSaveUsingBlock: ^(NSManagedObjectContext *context) {
435+ Comment *commentInContext = [context existingObjectWithID: commentObjectID error: nil ];
436+ if (commentInContext) {
437+ [context deleteObject: commentInContext];
438+ }
439+ } completion: ^{
440+ if (failure != nil ) {
441+ failure (error);
442+ }
443+ } onQueue: dispatch_get_main_queue ()];
444+ }];
433445 }
434446}
435447
You can’t perform that action at this time.
0 commit comments