Skip to content

[try] Image Size with networking on native client#1455

Merged
etoledom merged 25 commits intodevelopfrom
try/image-size-networking-native
Nov 20, 2019
Merged

[try] Image Size with networking on native client#1455
etoledom merged 25 commits intodevelopfrom
try/image-size-networking-native

Conversation

@etoledom
Copy link
Copy Markdown
Contributor

@etoledom etoledom commented Oct 17, 2019

Alternative to #1453

This PR pass the networking request intent to the client app, and awaits for a response.

As a proof of concept, this PR implements the minimum necessary to make Image Size works.
In the future we might need to pass the request method and parameters.

Related PRs:

To test on iOS refer to WPiOS PR: wordpress-mobile/WordPress-iOS#12714
To test on Android refer to WPAndroid PR: wordpress-mobile/WordPress-Android#10779

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

@etoledom etoledom added [Type] Enhancement Improves a current area of the editor Media labels Oct 17, 2019
@etoledom etoledom added this to the 1.16 milestone Oct 17, 2019
@etoledom etoledom self-assigned this Oct 17, 2019
@etoledom etoledom mentioned this pull request Oct 17, 2019
1 task
@hypest hypest modified the milestones: 1.16, 1.17 Nov 1, 2019
@etoledom etoledom force-pushed the try/image-size-networking-native branch from 4320681 to e675c61 Compare November 7, 2019 07:57
@etoledom
Copy link
Copy Markdown
Contributor Author

etoledom commented Nov 7, 2019

@mchowning FYI - Just rebased all relevant branches to keep them up to date.

@etoledom etoledom force-pushed the try/image-size-networking-native branch from 9a751e0 to e675c61 Compare November 8, 2019 08:11
return response;
};

return responsePromise.then( parseResponse ).catch( ( error ) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need the then/error if they're just returning the passed value?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've updated parseResponse so it no longer just returns the passed value like it used to. I made this change because I have Android returning a json string because that's much simpler to do. If there's an issue with that I can certainly update it to return a json object like iOS.

With respect to the catch clause, I believe adding that does change the behavior so that now the resulting promise essentially "resolves" with the error (i.e., the resulting promise will pass the error in any subsequent then calls). Seems like this probably is not desired behavior. What do you think @etoledom ?

@mchowning mchowning changed the base branch from develop to release/1.17 November 11, 2019 21:50
@mchowning
Copy link
Copy Markdown
Contributor

Hey @etoledom ! I merged the code from release/1.17 into this branch and updated the PR to target that release branch.

@mchowning mchowning marked this pull request as ready for review November 11, 2019 22:01
@etoledom
Copy link
Copy Markdown
Contributor Author

etoledom commented Nov 15, 2019

Overall it looks good to me ✅

I have found a few issues that I think are beyond this (Networking specific) PR:

  1. [WPiOS]: When selecting different a different image size, the image's size doesn't change visually. This is due to the Image.getSize call fails to return the correct size on urls with the form ...?w=100 (from what I tested), returning the full size all the time. Then this value is sent to the native side which uses Photon API to get the image with the given size.

  2. [WPiOS (Probably Android too)] When the image size request fails, Gutenberg won't ever request it again for the same image (on the same session). This might be a problem for users with bad connectivity.

  3. Given that the previous problem occurs for any reason (like no internet connection or a self-hosted endpoint failing), setting the image size will still succeed on updating the slug, but it will silently fail to update the image url to the proper one of the smaller size. I believe we could not show the Image Size picker option if we don't have the Images size information requested.

  4. The default Image Size slug is Large, but the actual image URL is the full size one. On web, a new added image has set the proper Large image URL.

  5. When an image has a slug set (let's say Thumb) and we change the image for a new one, the ImageSlug is not updated to the default one (it will remain as Thumb on this example).

'wp/v1/media/', // made up example
];

describe( 'isPathSupported', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love the tests for this.

Copy link
Copy Markdown
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

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

Tested this on iOS and it's working great.

I tested with WP.com normal, Atomic WP.com and self-hosted sites.

Love the use of Result and Promise in Swift and JS.

Great work.

@etoledom etoledom modified the milestones: 1.17, 1.18 Nov 19, 2019
@etoledom etoledom changed the base branch from release/1.17 to develop November 19, 2019 06:29
@etoledom etoledom merged commit 96d6f5d into develop Nov 20, 2019
@etoledom etoledom deleted the try/image-size-networking-native branch November 20, 2019 09:16
@maxme maxme mentioned this pull request Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Media [Type] Enhancement Improves a current area of the editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants