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

Conversation

yaelirub
Copy link
Contributor

@yaelirub yaelirub commented May 21, 2019

When a post fails to save, it status was set to AbstractPostRemoteStatusFailed which should have
made post.hasNeverAttemptedToUpload return true hence return false in shouldRemovePostOnDismiss in discardChanges().

let shouldRemovePostOnDismiss = post.hasNeverAttemptedToUpload() && !post.isLocalRevision

The problem was that the remoteStatus property was not really being saved. In order to save those changes we are merging the revisions back into the base post.

Fixes #11435

To test:

upload failed post with no changes

1.Be offline
2.Create a new draft
3.Save draft (either through options menu or by exiting the editor and choosing "save draft")
4.rerun xcode
5.See the post with "failed upload" status
6.tap on post
7.Exist editor
8.Choose discard
*Expected - post is not be deleted.

upload failed post with changes:

1.Follow steps 1-6 above
2.Make changes to post
3.Exit editor
4.Choose discard
Expected - Changes made in step 2 will be discarded and the post is not be deleted.
Before:
discard_offline_2

After:
discard_offline

Update release notes:

If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

…tusFailed which should have

made post.hasNeverAttemptedToUpload return true hence return false in shouldRemovePostOnDismiss in discardChanges().
The problem was that the remoteStatus property was not really being saved. In order to save those change
we are merging the revisions back into the base post
Copy link
Contributor

@jklausa jklausa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took me a while to wrap my head around why this was needed!

I... really dislike that we're doing [NSManagedObjectContext performBlock:] inside a network callback, but the success block was doing it already anyway, so ¯_(ツ)_/¯.

Great job tracking this down and fixing it!

@yaelirub
Copy link
Contributor Author

Thanks, @jklausa!

really dislike that we're doing [NSManagedObjectContext performBlock:] inside a network callback

I see your point. Hopefully the implementation of uploads manager will separate the network call from saving locally. At least for uploading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offline Support: Discard Losing all changes
2 participants