-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Restore autosave revision dialog #12947
Restore autosave revision dialog #12947
Conversation
A post is considered to have an autosave if the `autosaveModifiedDate` is not nil.
When a post containing an autosave is tapped, a dialog is presented to allow the user to make a choice between loading the post's current published version and the post's autosave version.
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
|
When a post is edited, the editor is loaded with the original post and then a revision is made. This order seems incorrect - the revision should be made _before_ being loaded into the editor. This change will allow autosave content that will be conditionally added to a post revision to be loaded into the editor.
If the user chooses to load a post's autosave content, their choice is propogated to both the Gutenberg and Aztec editors where it is loaded into the post revision created by the editors. This revision content is then loaded into the editors using the pre-existing editor functionality.
Renamed variables and removed explicit `self` reference when unnecessary.
Users are only asked if they wish to load a post's autosave changes if the post has NO local changes.
A recent commit undid the code to load autosaves, this is now fixed.
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.
Great work, @guarani!
- Tested Aztec ✔️
- Tested Gutenberg ✔️
- Confirmed the labels are correct ✔️
- Simulated a crash
⚠️ - Tested the dialog will not show if there is a local change ✔️
- Tested Pages ❓
Possibly confusing labels
An autosave can be created on the same device the post is later loaded on - so the dialog labels "From this device" and "From another device" don't always seem intuitive
Similarly, if the autosave is created on a device (e.g. changes are previewed), then the user exits the editor and discards the changes, the option to load the autosaved (discarded) changes is still available
Good job finding this, @guarani.
Yeah, this seems like a flow that we did not anticipate.
Do you have some suggestions to circumvent this?
@osullivanchris, what do you think about this scenario? Should we rename the buttons? Or should we make the Discard Changes button also discard the remote autosave (seems dangerous)? Or just leave this be for now?
Incorrect label after crash simulation
I simulated a crash using these steps:
- Create a post on the device and published it
- Created an autosave in the browser
- Edited the post on the device. Chose “From another device” in the dialog.
- After a few seconds that the editor is shown, I force-closed the app
- Reopened the app
In the Post List, the cell shows “You've made unsaved changes to this post”. However, when I click on the cell, the dialog is not shown. The expected message should most probably be “Local changes”.
We probably just need to add another condition in PostCardStatusViewModel
.
Pages
It doesn't look like this works in pages. But I realized that the code is quite different. This should be a different task.
Others
I think this is worthy enough to add some release notes. 🙂
WordPress/Classes/ViewRelated/Post/PostCardStatusViewModel.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/Extensions/AbstractPost+PostInformation.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/Extensions/AbstractPost+PostInformation.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
Thank you @shiki for the thorough review! Possibly confusing labels
If Android ensures the autosave revision is always kept up-to-date with the editor contents - even when discarding content - while iOS currently does not then my suggestion would be to bring iOS behavior inline with Android (if this agrees with the intended user experience for iOS). Incorrect label after crash simulation
If I'm understanding correctly, in this scenario you killed the app after simply opening the editor and viewing the autosave - you didn't make any changes to the content - is that correct? If that's the case, I would have thought that showing "You've made unsaved changes to this post" is correct because no local changes have been made. I agree of course that the autosave dialog should be shown though. Pages
Ok - I agree pages seem best suited to a different issue. Others
Yes, thanks for the reminder :) I've added a note for 13.8, which is the PR milestone. |
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
That's correct. Please see this video. This is an edge case. If having a “Local changes” label is easier to implement, I think we can do that. |
WordPress/Classes/ViewRelated/Post/AlertViewController+Autosave.swift
Outdated
Show resolved
Hide resolved
WordPress/Classes/Extensions/AbstractPost+PostInformation.swift
Outdated
Show resolved
Hide resolved
Post autosave identifier is now persisted via core data to `AbstractPost`.
An autosave is available iff there is an autosave identifier greater than zero.
To keep PostListViewController lean, move the logic for editing posts (or loading their autosave revision) into a presenter.
All editors (Gutenberg and Aztec) support loading autosave revisions. A required initializer is now defined in the PostEditor protocol to ensure this dependency is always satisfied.
The autosave dialog was previously on the UIAlertController static namespace, even though it has a one-off use case. Now it's in a custom presenter and kept private.
Generated by 🚫 dangerJS |
Added check to post card status view model to ignore autosave status label if post has local changes.
Using a "local" remote status for the post is wrong because it interfers with the requirement that posts with local changes should not show the status.
I took a look at the 'leaving the editor' behaviour before. I prefer the Android solution. You can see a sketch or refer to paCBwp-d6-p2
I had a similar conversation with Jirka on Android. I'm not sure if its the same scenario. But we basically found that each time the user opens a post with a conflict, until they make a committing change e.g. save/publish, we will have to show them the dialogue every time they open the post. The only way to avoid that is to force the user to make a decision. Keep one to move forward with.
Yeah that doesn't sound like what I want to do when I'm discarding changes. I would see 'discard changes' as meaning discard what I have done within this editing session. Agree?
Not 100% certain I understand but I feel like I agree with this. See my first comment about discarding on Android. Is this similar? General pointEvery time I jump back into something related to offline, it honestly takes me a huge context switch. Just reading this post has taken me about an hour! Its definitely possible that I'm just stupid, but I don't feel thats entirely to blame. I think that all the flows around revisions and local changes, etc are far too complex. Sure, there is probably an inherent amount of complexity that we cannot get rid of. But it feels like we allow too much flexibility. I think we are continually patching the current UX and the quicker we can break the paradigm the better. I think in the future I would in the system:
As I'm struggling to understand the current system, I'm sorry if the answers prior to this general point are not conclusive enough |
I feel you. And I'm sorry for dragging you into this conversation. 😐 Thank you for your time! 🙏
That makes sense and it sounds related to this.
I agree. 👍
As I understand it, yes. We should remove that dialog altogether. And I agree. Unfortunately, this was deemed out of the scope of the Offline Posting project in paCBwp-e5-p2. I added a note of it in the description of #11435 to make the decision/recommendation discoverable. Summary@guarani, based on this discussion, we can leave the Possibly confusing labels alone for now. |
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.
Looking good, @guarani! I love the progression of the commits. Very easy to follow. I also appreciate the comments. Thank you for adding those!
I have a couple of questions from the recent changes. We also need to fix the conflicts. After that, we're good to go!
WordPress/Classes/WordPress.xcdatamodeld/WordPress 94.xcdatamodel/contents
Outdated
Show resolved
Hide resolved
WordPress/Classes/ViewRelated/Post/PostListEditorPresenter.swift
Outdated
Show resolved
Hide resolved
An enum has the advantage of not being able to be instantiated, but does hinder the readability of the code.
This is due to the core data migration. |
I noticed that there was a line in release notes that shouldn't be there (it duplicated an existing line): > * Block editor: Images from Image Block can now be previewed full screen by tapping on them. This line was introduced in 6716fc8 and moved in ffdbfdb. It looks like a merge or conflict was not properly resolved at some point on my feature branch resulting in the move commit not being cleanly applied (line was added to a new line position but not deleted from its old position). This looks like the only inadvertent change - all else looks fine.
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.
Thank you, @guarani! 🎉
Overview
Fixes #12141
On the post list screen, posts with an autosave revision are now marked with a new status label. When tapped, instead of just loading the post as before, users are now also given the option to load the autosaved revision. Loading the autosave revision works in both the Gutenberg and Aztec editors.
Demo
Testing Steps
Notes
Update release notes:
RELEASE-NOTES.txt
if necessary.