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
Send changed
to the native bridge if html changed since last time
#242
Conversation
cc @hypest |
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.
Tested with the WPiOS app and working OK. 👍
If I understand the code correctly, it detects the change compared to the last time it was sent up to the parent. I think that's not the intended logic and it's not what it was in place before. Because it seems that parsing and then serializing the blocks again does not produce the original html, we need to check if the html we pass back to the parent is the same as the html originally passed down to the RN app. The previous solution was keeping the md5 hash of the original html so to compare it with the current and report "changed" or not. I tested with the wpandroid integration and indeed, the post is reported as "changed" with the current PR ( |
That's right @hypest I missed this because this flag is not utilized in iOS side while closing the editor. There's an internal logic to decide if content has changed so it is not using the Javascript flag while closing. I am just setting the last version of html and it is taking care of the rest(to give more detail, it creates a revision on opening and compares the new content with that revision), if there's no change it just closes the editor without extra prompts. The only use case of such a flag on iOS side is enabling/disabling the Publish button. Currently the publish button is always active because we don't have the capability yet on the Gutenberg side that informs us the every editing action unlike Aztec. So it turns out currently I am not actually utilizing that flag. 🤔 (I mean I am using it but it is ignored.) |
btw this PR #243 makes it possible to get a more decent test result, it is not merged to master yet so I did a temp merge to my own branch directly from that PR. |
Where does that logic live? Is it the parent app, the bridge or the RN layer? Since what we're dealing with here are involuntary changes by the editing component itself, the logic needs to live in the RN side and the initial "snapshot" to compare against needs to take into account those self-inflicted changed. That's why the original implementation needed to serialize the blocks again before it computed the "initial hash". See here in the original PR: https://github.com/wordpress-mobile/gutenberg-mobile/pull/225/files#diff-969b5637d99e6ae15745bc85e7f3519fR16 cc @Tug as this relates to what to consider "initial html". |
@hypest In the parent iOS app. If you want to dig more into it you can check out the class AbstractPost, there's a hasLocalChanges method in it. It simply compares the latest content with its original content and returns the result, this has always been this way. Whenever user makes a change on aztec editor the lates content in the post is updated, "hasLocalChanges" is computed where necessary. So what happens is:
There are huge differences between iOS and Android apps both in terms of user experience and implementation. So I am having hard time saying both sides need the exact same flag. I think we can move this conversation to the #mobile-gutenberg |
#226 caused a regression in the js to native bridge. We're not sending the
changed
parameter anymore when callingprovideToNative_Html
. This PR fixes it.