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

RNMobile: Only fetch image data if image url is not a local file #20202

Conversation

mchowning
Copy link
Contributor

@mchowning mchowning commented Feb 12, 2020

Related gutenberg-mobile PR

Description

Addresses wordpress-mobile/gutenberg-mobile#1853 by not attempting to fetch an image that has a local file path url. This avoids accidentally fetching the wrong image when the local image id conflicts with a different remote id.

How has this been tested?

  1. On Android, add photos from the device to image blocks until the incrementing local id of the newly-added photo conflicts with the remote id of a photo for the site. Using an emulator and taking a snapshot of the device immediately before you add the photo that will have the conflicting id is handy for testing.
  2. Observe that when the photo is uploading the placeholder only displays the correct newly added photo and does not ever display the photo with the conflicting remote id.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@mchowning mchowning added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Feb 12, 2020
Copy link
Contributor

@mkevins mkevins left a comment

Choose a reason for hiding this comment

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

I tested this on Pixel 3a (Android 10) via the steps described here: wordpress-mobile/WordPress-Android#11239 (comment) and this indeed addresses the "symptoms" exhibited within the Image block, and fixes wordpress-mobile/gutenberg-mobile#1853 as described.

I was also able to reproduce the issue noted here: wordpress-mobile/gutenberg-mobile#1896. A solution to that may require more investigation, and might be out of scope for this PR.

Nice work @mchowning 👍

@@ -78,6 +78,8 @@ const getUrlForSlug = ( image, { sizeSlug } ) => {
return get( image, [ 'media_details', 'sizes', sizeSlug, 'source_url' ] );
};

const isFileUrl = ( url ) => url && url.startsWith( 'file:' );
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 I like this extraction

@mchowning mchowning merged commit 56ff721 into master Feb 14, 2020
@mchowning mchowning deleted the rnmobile/issue/1853_image-upload-preview-incorrect-on-id-conflict branch February 14, 2020 11:46
@github-actions github-actions bot added this to the Gutenberg 7.6 milestone Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants