-
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
fix: Avoid unexpectedly marking post content as unsaved #23969
fix: Avoid unexpectedly marking post content as unsaved #23969
Conversation
Generated by 🚫 Danger |
These changes look good. The previous implementation was temporary. As you noted, the default implementation should be enough. Some background: |
The custom `editorHasChanges` implementation resulted in an always-"dirty" state, even after saving changes via the "Update" or "Save draft" buttons. This removal, results in the editor relying upon the existing `editorHasChanges` implementation, which appears to be more accurate. https://github.com/wordpress-mobile/WordPress-iOS/blob/388dbb167b7ae6fd763ed4c90076dc94679a9dc6/WordPress/Classes/ViewRelated/Post/PostEditor.swift#L81-L83
3d293fa
to
bfad96f
Compare
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
@kean thank you for providing that helpful context. I was unsure about the rationale for the custom implementation. From my testing, using the default implementation works as expected. FYI, a similar approach was taken for the |
Tbh, I don't remember. I think it was needed for an early prototype where the editor couldn't communicate the content changes to the app. Out of curiosity, how is it done now? |
A generic store subscription broadcasts content changes to the host app. The host app throttles persisting the changes. There is likely opportunity to improve this approach. |
The autosave is performed very infrequently. Its main purpose is to periodically write to disk to protect content from a crash. The assumption is that converting blocks to strings and transferring those from the editor to the app is expensive, so we avoid doing it as much as possible.
It will need some performance testing, but AFAIK it shouldn't be an issue as long as there are no expensive calculations. It will keep the app (navigation bar) state up to date, which is nice, but this is not the case in Gutenberg Mobile. The idea in If the editor needs to transfer some state in "real time", it should use EditorState. It's lightweight, and it takes no time to decode/encode, so it can be used freely and frequently. |
* fix: Avoid unexpectedly marking post content as unsaved The custom `editorHasChanges` implementation resulted in an always-"dirty" state, even after saving changes via the "Update" or "Save draft" buttons. This removal, results in the editor relying upon the existing `editorHasChanges` implementation, which appears to be more accurate. https://github.com/wordpress-mobile/WordPress-iOS/blob/388dbb167b7ae6fd763ed4c90076dc94679a9dc6/WordPress/Classes/ViewRelated/Post/PostEditor.swift#L81-L83 * docs: Add release note * docs: Fix release notes errors originating from rebasing
The custom
editorHasChanges
implementation resulted in analways-"dirty" state, even after saving changes via the "Update" or
"Save draft" buttons. This removal, results in the editor relying upon
the existing
editorHasChanges
implementation, which appears to be moreaccurate.
WordPress-iOS/WordPress/Classes/ViewRelated/Post/PostEditor.swift
Lines 81 to 83 in 388dbb1
Fixes https://github.com/Automattic/dotcom-forge/issues/10114.
To test:
1: Update published posts
2: Update draft posts
Regression Notes
Introduce post state bugs.
Manually test creating/saving/updating/publishing posts.
Deemed unnecessary for the experimental editor.
PR submission checklist:
RELEASE-NOTES.txt
if necessary.Testing checklist: