Make app more resilient to empty post-formats. #11832
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #11662 (and sorry, I ended up making a bit long description 🙃)
This PR is a companion to the real solution that is in the wordpress-mobile/WordPress-FluxC-Android#1575
Was able to reproduce the issue (with 14.5 and current develop) in a JN self-hosted site both adding it to the app as a JetPack or by site address.
I think the issue is due to the fact that the post-formats we support (and I'm not talking about the post types) are not meant to be customized but with some hack like this you can get them renamed and if you do not do it well you can end up sending empty strings for some of the post-formats category.
In the FluxC PR I added some check to consider not valid an empty post-format.
Notes for reviewer
Gallery
andAside
Gallery
andAside
also, we behave like the block editor (using default names) in the app Editor Post Settings but show the customized names in the Site Settings. Not sure if it's worth changing this since AFAIU post-formats customization is not a feature we support, so in my understanding to make the app more resilient to the eventual issue should be enough (let me know wdyt).
To test
Reproduce the issue
Evaluate and Log
breakpoint as below for self-hosted and WPCOM API relevant code((Map)(response = (new java.util.HashMap<String, String>()))).put("Image", "")
(response.formats = new java.util.HashMap<String, String>()).put("image", "")
Check the fix
Smoke test
As per title 😊, smoke test the app got from the current PR especially in Site Settings and Editor Post Settings sections.
PR submission checklist:
RELEASE-NOTES.txt
if necessary.