Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix discard draft loosing all changes #11736

Merged
merged 1 commit into from
May 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion WordPress/Classes/Services/PostService.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,13 @@ - (void)uploadPost:(AbstractPost *)post
};
void (^failureBlock)(NSError *error) = ^(NSError *error) {
[self.managedObjectContext performBlock:^{
Post *postInContext = (Post *)[self.managedObjectContext existingObjectWithID:postObjectID error:nil];
AbstractPost *postInContext = (AbstractPost *)[self.managedObjectContext existingObjectWithID:postObjectID error:nil];
if (postInContext) {
if ([postInContext isRevision]) {
postInContext = postInContext.original;
[postInContext applyRevision];
[postInContext deleteRevision];
}
postInContext.remoteStatus = AbstractPostRemoteStatusFailed;
// If the post was not created on the server yet we convert the post to a local draft post with the current date.
if (!postInContext.hasRemote) {
Expand Down