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

Image: support ImageSource with headers #8

Closed

Commits on Dec 21, 2022

  1. [add] load images with http headers

    - extend ImageLoader.load params
    - Removed the old `image.decode` change as it's covered by the minimal browser versions supported here
    - add examples for Images with headers
    - Image - remove requestRef - no longer needed
    - rename `ImageLoader.abort` to `.release`
        The method is mostly used as cleanup
    (e.g. useEffect cleanup, or releasing resources when component unmounts)
    - Image - extract `useSource` hook
        Move the image loading effect here
        Changed the original logic slightly for less nesting
        Changed to cover cases where passing the same headers object was starting new loads, as it was treated as a different value due to referential equality
    - Image - add tests covering added/changed functionality around source
    - Image - handle cases where the source object only changes by reference
        When the source object changed by reference, but stays structurally the same, we should do nothing and not trigger the loading effect again
    - Image - extract ImageLoadingProps
        Update types to match RN and actual code - we don't call `onLoadStart` and `onLoadEnd` with any arguments
    - ImageLoader extract types.js
    - Image - resolve `onLoad` with `source`
        Use the same `nativeEvent` structure as in RN for the onLoad event
    - Rework Image loading and source management logic
        Since introducing the change to support headers changes to the original
        changes are needed:
        - support loading a default source with headers
        - handle source object changes
        - update uri resolving logic to handle blob URLs create by `URL.createObjectURL`
        - move the URI/source resolving logic to the `ImageLoader`
    
    BREAKING CHANGE
    `onLoad` was previously called with `nativeEvent` that was the browser Event object
    from the image.onload handler
    Since we can't spread or mutate the Event object to add `source` we have to
    either add it under a new key or remove it
    The browser Event does not expose very useful information, (no target, or size info),
    so it seems best to replace `nativeEvent` with the same structure used in `react-native`
    kidroca committed Dec 21, 2022
    Configuration menu
    Copy the full SHA
    32f1137 View commit details
    Browse the repository at this point in the history
  2. [fix] ImageLoader images are not added to ImageUriCache

    Previously loaded images used to be added to ImageUriCache
    It seems the logic was accidentally removed here: necolas@f4e8b6b#diff-7cb74a3a32d73857be80350ecd1ea131d256bd5af11d2000e4fc2d03c2230584L361
    
    And now the `ImageUriCache` is only updated by preload/getSize
    kidroca committed Dec 21, 2022
    Configuration menu
    Copy the full SHA
    e2248d6 View commit details
    Browse the repository at this point in the history

Commits on Jan 4, 2023

  1. Apply suggested typo fixes and clarifications

    Co-authored-by: Alex Beaman <dabeamanator@gmail.com>
    Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
    Co-authored-by: Tim Golen <tgolen@gmail.com>
    4 people authored Jan 4, 2023
    Configuration menu
    Copy the full SHA
    6429c1e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9ef7d28 View commit details
    Browse the repository at this point in the history
  3. Remove resolveBlobUri

    kidroca committed Jan 4, 2023
    Configuration menu
    Copy the full SHA
    7b9f633 View commit details
    Browse the repository at this point in the history
  4. Image code comments

    kidroca committed Jan 4, 2023
    Configuration menu
    Copy the full SHA
    d90e85c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    26c1ae9 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    7c6f58e View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2023

  1. Fix comment typo

    kidroca committed Jan 5, 2023
    Configuration menu
    Copy the full SHA
    33cb405 View commit details
    Browse the repository at this point in the history
  2. Reducing changes

    kidroca committed Jan 5, 2023
    Configuration menu
    Copy the full SHA
    9edf19b View commit details
    Browse the repository at this point in the history

Commits on Jan 6, 2023

  1. Clarify code comments

    Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
    kidroca and marcaaron authored Jan 6, 2023
    Configuration menu
    Copy the full SHA
    4227410 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    10df92e View commit details
    Browse the repository at this point in the history
  3. Fix callbacks ref

    Extract callbacks from ref before usage - not when
    loading starts
    kidroca committed Jan 6, 2023
    Configuration menu
    Copy the full SHA
    9d6cbe7 View commit details
    Browse the repository at this point in the history

Commits on Jan 9, 2023

  1. Alter onLoad breaking change

    We append `source` to the `nativeEvent` raised by the Image.onload event
    in order to preserve existing functionality but mach the `source` object
    available in react-native's image load event
    kidroca committed Jan 9, 2023
    Configuration menu
    Copy the full SHA
    42ef468 View commit details
    Browse the repository at this point in the history