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

Use a single method to retrieve title and content from Gutenberg #15508

Merged

Conversation

mkevins
Copy link
Contributor

@mkevins mkevins commented Oct 29, 2021

Related PRs:

gutenberg: WordPress/gutenberg#36072
gutenberg-mobile: wordpress-mobile/gutenberg-mobile#4182

Description

This synchronizes the content retrieval mechanism for serializing content from the editor, and includes title and content in a single event. See WordPress/gutenberg#36072 for more details.

Regression Notes

  1. Potential unintended areas of impact
    Autosave behavior

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manual testing was conducted as part of a task force to address ongoing issues with the autosave mechanism.

  3. What automated tests I added (or what prevented me from doing so)
    These changes involve modifications to the mechanism to serialize content over the bridge to address a race condition. Creating the necessary configuration to test integration of our React Native bridge implementations and protocols is out of scope for the autosave task force project, however, this could be very valuable as a future project.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

This modifies the API used to retrieve both the title and serialized
content from the Gutenberg editor from one event, and includes Gutenberg
changes to synchronize access to the latch used to suspend execution in
the mechanism awaiting response.
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Oct 29, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Nov 2, 2021

You can test the changes on this Pull Request by downloading the APKs:

@mkevins mkevins added this to the 18.7 milestone Nov 4, 2021
@mkevins mkevins marked this pull request as ready for review November 4, 2021 05:12
String content = (String) mEditorFragment.getContent(oldContent);
String title, content;
// To reduce redundant bridge events emitted to the Gutenberg editor, we get title and content at once
if (mEditorFragment instanceof GutenbergEditorFragment) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ I'm wondering if we need this if statement. Both Guteneberg fragment and Aztec fragment provide getTitleAndContent(..) method, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I refactored the implementation to remove getTitle method from the interface (since it is no longer used anywhere), and now that method is private in Aztec. This allows us to simplify this and remove the conditional here.

This is no longer an interface method and can be made private.
Since Aztec and Gutenberg can both use the same interface method, there
is no longer a need to condition on the fragment instance type.
Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Great work @mkevins 👍
I tested with WordPress/gutenberg#36072 (review) on a Pixel 5 (Android 12) and everything worked as expected. The code changes also LGTM 🎉

@mkevins
Copy link
Contributor Author

mkevins commented Nov 7, 2021

Thank you for reviewing and testing!

@mkevins mkevins merged commit 7336f93 into develop Nov 7, 2021
@mkevins mkevins deleted the fix/synchronize-content-serialization-over-the-bridge branch November 7, 2021 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants