-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Auto-upload/save all posts/pages with local changes #10319
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
Auto-upload/save all posts/pages with local changes #10319
Conversation
…-changes-confirmed-at # Conflicts: # WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java # WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt # build.gradle
…pdate-changes-confirmed-at # Conflicts: # WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java # WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt # build.gradle
…-changes-confirmed-at # Conflicts: # WordPress/src/main/java/org/wordpress/android/ui/posts/PageAndPostListPreviewStateHelper.kt
…firmed-at # Conflicts: # WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadStarter.kt # WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java # build.gradle
WordPress/src/main/java/org/wordpress/android/ui/posts/PreviewStateHelper.kt
Show resolved
Hide resolved
Generated by 🚫 dangerJS |
shiki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at this today. I have some comments and this question:
Prevent auto-uploading posts which are in conflict with remote
Why?
WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadStarter.kt
Outdated
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadStarter.kt
Show resolved
Hide resolved
Which one should be merged first? |
maxme
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to make sure things work well for self hosted sites before merging this.
PS: The "local draft" and "local changes" status on auto-saved draft/post/page feels a bit weird to me (I'm not expecting changes being available on the server when I see this label), it's not a big deal though.
WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadStarter.kt
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java
Show resolved
Hide resolved
WordPress/src/main/java/org/wordpress/android/ui/posts/PostPreviewActivity.java
Outdated
Show resolved
Hide resolved
…mote-auto-save-when-leaving-editor Invoke remote-auto-save when exiting the editor
Sounds good! |
…hout-changes-remote-auto-saved Don't save post when it wasn't edited during the current session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going well. Almost there! I tested this with a self-hosted site today and found these.
- Reverting a Published Post into a Draft
- Preview error in the editor
- Extra labels for canceled drafts
Reverting a Published Post into a Draft
There does not seem to be a way to revert a published post into a draft. Using develop (870511b), I can do this and it works:
- Edit the published post.
- Navigate to Post Settings. Change the Status to Draft.
- Exit the editor by pressing the back button.
- The post will be automatically uploaded and reverted into a draft.
With this change, I get a “Draft is uploading” but it always ends up in the Post List saying these in sequence:
- Couldn't perform operation
- Local changes
Here is a video showing this.
Preview error in the editor
I'm not sure if this is because of this PR or because of the preview changes.
- Go offline.
- Create a draft. Do not leave the editor.
- Turn on the internet connection.
An upload will start in the background and an error related to previewing will be shown.
Extra labels for canceled drafts
This could probably use a design input. When canceling Private or Pending review local drafts, their status is still appended after the “Local draft” label.
- Go offline.
- Create a draft and set it to Private or Pending review.
- Exit the editor.
- In the Post List, press the Cancel button.
Please let me know if some of these should be out of scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed media uploads and publishing
I just wanted to confirm if this is expected. I believe you mentioned this a bit during the call. Currently, if a post has a failed media upload, it will always be uploaded as a draft even if the user confirmed publishing it. This video shows what I mean. Here are the steps:
- Go offline.
- Create a post and add an image. The media should fail to upload.
- Press the Publish button. The error shown will not be the usual “Post will be published...” error.
- Go online. The image will be uploaded and the post will be uploaded as a draft, not automatically published.
- RFC on Failed media uploads and publishing
|
Thank you @shiki!
Hmm, I don't see the "Couldn't perform operation" error. Just the "Local changes" label and it seems like an expected behavior. The user hasn't confirmed the changes, they need to manually click on "SAVE" (in the overflow menu).
I'm not able to reproduce this one. I checked the places where we show this specific message and it shouldn't be shown unless the app thinks it's in "preparing" for preview state. @maxme Do you have any tips what might be causing this issue?
I'm not sure I follow what is the issue here. Are you suggesting we should hide the "Private/Pending review" labels if the post is still a local draft -> since when the connection returns we'll upload it as draft and clear the "Private/Pending review" status? If this is what you meant I'm not sure it's a good idea as if the user clicks on Publish again (after canceling the auto-upload) the post will be published as Private/Pending Review - so the label is imho still valid. Wdyt? Btw I found another bug
I've fixed this issue in fe9e162. It's in the |
That's weird, I just tried this and the draft was uploaded while I was in the editor (I think you got an error, sometimes we get the "network status" event, but the network is not yet ready to do any request). The message is confusing, I wonder if we're in a wrong state in EditPostActivity. I'm not sure what triggers this auto-upload, I'll check that first. Note: I just noticed we should update the method name WordPress-Android/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java Line 4162 in 0910bb0
|
Auto-upload is triggered by the UploadStarter, after the post is pushed, I get the I tried to track how That makes me wonder if the snackbar you see comes from this line: WordPress-Android/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java Line 4136 in 0910bb0
@shiki can you try to repro this one and check the state of |
|
@malinajirka In response to #10319 (comment):
I didn't realize there was a Save button there. 🤦♂ Seeing that I myself was confused, I think we should change this. But not in this PR. Would you mind creating a separate issue for it? We can ask Chris for his input. The issue is probably a nice-to-have in the context of the Offline Posting project.
Yeah, you're right. Ignore me. 😁 |
@malinajirka This is fixed. Thank you. My remaining concern is that the error message in the Post List does not mention that the post will be published automatically. I'm okay with this being done in a separate PR so we can collect all the PRs in the master branch.
|
|
@maxme In response to #10319 (comment):
Uhm, I can't reproduce it anymore. 😐 I guess we can close this out for now. Thank you for checking it! |
|
|
|
Created issues for the remaining tasks: |



Fixes #10174
This PR changes more than I initially planned. I think it'd be worth considering doing a pair/triple-review with me so I can explain the changes. Please let me know if that's what you prefer to do;).
Main changes
PostModel.changesConfirmedContentHashcode is a field which we use to mark that the current set of changes has been explicitly confirmed by the user. Whenever the user explicitly confirms the chagnes - clicks on Publish/Update/Schedule/Submit/Save/Sync/... button, we calculate a hashcode of the content of the post and save its value into the
changesConfirmedContentHashcodefield. When we are about to upload the post we calculate the hashcode again and if it matches the value stored inchangesConfirmedContentHashcodewe are sure the post hasn't been changed since the user confirmed the changes and we can safely upload it.PostUploadHandler is the place where we decide whether the post will be uploaded, uploaded as draft or remote auto saved.
Uploaded are posts with changes which have been explicitly confirmed by the user -> the user clicked on Publish/Update/Schedule/Submit/Save/Sync... buttons.
Uploaded as drafts are local drafts (PostModel.isLocalDraft == true) with changes which haven't been confirmed by the user. We can't remote auto save them as they don't exist in the remote.
Remote-auto-saved are all other changes. This feature isn't supported on self-hosted sites, therefore we don't sync the changes with the remote on self-hosted sites unless the user explicitly confirms them.
To test:
This PR touches
We decided we'll test these changes when we implement #10207
Update release notes:
RELEASE-NOTES.txt.Notes:
master-auto-uploadwhich was created frommaster-remote-preview.