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

Optimize Contentful image loading #593

Merged
merged 14 commits into from
Jul 19, 2018

Conversation

Lily418
Copy link

@Lily418 Lily418 commented Jul 6, 2018

Implemention for #587

Render transparent image initally and then request an image of the rendered size.

Tester check-list

  • Tested on multiple devices / OS versions (Test on the physical device(s) you have access to, otherwise use BrowserStack):

    • Galaxy S8 (Android 7.0/8.0)
    • Galaxy S7 (Android 6.0)
    • iPhone X (iOS 11.x)
    • iPhone 8 (11.x)
    • iPhone 7 (iOS 10.x)

    Optional:

    • Google Pixel 2
    • Galaxy S8 Plus
    • Galaxy S7 Edge
    • Galaxy S6
    • iPhone 7+
    • iPhone 6

…progress implementation of ImageBackground that uses static values
@Lily418 Lily418 added the wip label Jul 6, 2018
@Lily418 Lily418 changed the title WIP: Optimise Contentful image loading WIP: Optimize Contentful image loading Jul 6, 2018
@Lily418 Lily418 changed the title WIP: Optimize Contentful image loading Optimize Contentful image loading Jul 9, 2018
Copy link
Contributor

@frigus02 frigus02 left a comment

Choose a reason for hiding this comment

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

Looks mostly good. I would add a safety null check for an existing image to be safe.

We had crashes in the beginning because we had references to non-existing featured events, which was quite annoying. (A draft event was selected as a featured event. So we got the reference to it, but not the event object itself.)

}

const imageDetails = images[id];
const imageUriWithResizingBehaviourParameters = `${imageDetails.uri}?w=${
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not count on the image details being present all the time, i.e. imageDetails might be undefined.

I think it might be possible in Contentful to select an image in an event, which is still a draft. This means we get the event with the image id. But we don't load the image because we only download published images.

this.state = { imageSize: null };
}

onLayout = (event: Object) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

React Native exposes the flow type for the layout event. You could use this here.

Example:

import type { LayoutEvent } from "react-native/Libraries/Types/CoreEventTypes";

measureContentHeight = (event: LayoutEvent) => {
this.setState({ contentHeight: event.nativeEvent.layout.height });
};

@frigus02
Copy link
Contributor

@Lily418 Btw, you might want to update your git settings for user.email so GitHub can link your commits to your profile. Currently your author is Lily Hoskin <[email protected]> 🙂

@Lily418
Copy link
Author

Lily418 commented Jul 19, 2018

@frigus02 Thank you, have updated with a new test for that case and updated based on other comments

Copy link
Contributor

@frigus02 frigus02 left a comment

Choose a reason for hiding this comment

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

Nice. Looks good 👍

@Lily418 Lily418 merged commit 80840a6 into master Jul 19, 2018
@Lily418 Lily418 deleted the gh-587-contentful-image-loading-resize branch July 19, 2018 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants