-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 Web/Desktop: Add support for http headers #34505
Image Web/Desktop: Add support for http headers #34505
Conversation
- Introduced `BaseImage` component that branches between native and web implementations. - **Native**: Utilizes `FastImage` directly. - **Web**: Minor adjustments made to the `onLoad` event signature for compatibility. - Eliminated `Image/index.native.js` as both native and web components now leverage a unified high-level implementation for image loading and rendering. (cherry picked from commit 2aa37d2)
(cherry picked from commit 19b605e)
This patch focuses on resolving issues encountered with avatar image loading, specifically addressing the challenges related to CORS (Cross-Origin Resource Sharing) errors. Changes: - Removed the `isAuthTokenRequired` flag from the `AttachmentModal` component in various files, including `ProfilePage.js`, `RoomHeaderAvatars.js`, and `DetailsPage.js`. This change is crucial for loading of avatar images that are hosted externally. Rationale: - The primary purpose of this modification is to streamline the loading process for avatars by removing the unnecessary inclusion of authentication tokens in requests for external images. This approach aligns with standard practices for handling externally hosted content and aims to enhance compatibility and performance. - Raised a question here as whether there are cases of avatar images that need authentication: https://github.com/Expensify/App/pull/24425/files#r1404352872 This update is expected to resolve the CORS errors associated with avatar image loading, thereby improving the overall functionality and user experience in our application. (cherry picked from commit cc49208)
(cherry picked from commit 1182c7d)
- Adapt to `expo-image` deprecation of `event.nativeEvent` usage. - Directly use the event object as recommended. - Ensure compatibility with components using the `onLoad` prop.
@0xmiroslav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Is this exact same PR as #13036? All new files should be written in TS. Let's do that |
@0xmiroslav
It has slight changes, so it's not exact.
Allright |
cb435b5
to
d51126f
Compare
Author checklist is failing |
I had a little bit of trouble running the Android build, but resolved it today and added screenshots. ✔️ Ready for review |
@Beamanator can you please generate adhoc build? |
@Beamanator this PR will conflict with #31296. Should we hold this or continue? |
@0xmiroslav good idea, I just triggered that build |
Good call, but I think that's fine - whichever gets merged first won't have to deal with merge conflicts :D |
@blazejkustra or @fabioh8010 can you please review this PR in TS aspect? 3 new files are added. |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea, we could merge this PR with Ts migration and merge as one. Left one comment
src/components/Image/types.ts
Outdated
type ImageProps = { | ||
/** Event called with image dimensions when image is loaded */ | ||
onLoad?: (event: {nativeEvent: {width: number; height: number}}) => void; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImageProps are missing some props, you can copy them from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing out the ImageProps
. I've reviewed the reference from here and appreciate your suggestion. However, I have some reservations about incorporating these types into my current Pull Request, as they seem tangential to the specific change I'm introducing:
- History of Changes: The file you referenced has undergone several revisions. Directly copying it might inadvertently overwrite its existing history, leading to potential misattribution of changes.
- Irrelevant Props: Some of the props, such as
isAuthTokenRequired
, are not relevant to theBaseImage
component. Including them could introduce unnecessary complexity or errors. - Platform Specificity: The
BaseImage
component is tailored for specific platforms. Using the fullImageProps
could lead to compatibility issues between Expo and React Native Web image, given their differences.
Given these concerns, I propose two alternatives:
- Option A: We could remove the
types.ts
file from this Pull Request and defer its introduction to the other PR, maintaining clarity and separation of concerns. - Option B: Alternatively, we could rename the type to
BaseImageProps
and limit its scope to only include essential props likeonLoad
, ensuring compatibility and relevance to the current changes.
I believe either approach would maintain the integrity and focus of the Pull Request while addressing the need for proper typing. I'm open to further discussion on this matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blazejkustra what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kidroca Thank you for your perspective on this one! And I agree with you. Both options sounds good to me, although I'm more inclined to option B.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed an update that implements option B
yes, I thought the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides @blazejkustra comments!
I will need to take this over again as @0xmiroslav is no longer C+ |
Please fix conflict |
# Conflicts: # src/components/RoomHeaderAvatars.js # src/pages/ProfilePage.js
✔️ Done |
👋 assigned you @aimane-chnaif |
This comment was marked as resolved.
This comment was marked as resolved.
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully pass staging this time 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🙏
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/Beamanator in version: 1.4.35-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.35-7 🚀
|
Details
This PR refactors the
Image
component, aligning the web/desktop and native implementations for better consistency and maintainability.Changes:
Introduced
BaseImage
Component:src/components/Image/BaseImage.tsx
onLoad
event, it ensures that both web and native platforms have the same signature.Native Implementation Update:
src/components/Image/BaseImage.native.tsx
expo-image
, with a slight adjustment for theonLoad
prop, to make it's interface uniform.Unified Image Component for Web/Desktop and Native:
src/components/Image/index.js
Image
component has been refactored to use the newBaseImage
.Removed Redundant Native Specific Implementation:
src/components/Image/index.native.js
Patch for
react-native-web
patches/react-native-web+0.19.9+005+image-header-support.patch
Fixed Issues
$ #12603
PROPOSAL: N/A
Tests
Verify the Image component works on all platforms
X-Chat-Attachment-Token
header.X-Chat-Attachment-Token
value changes.Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop