-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[CP Staging] Fix crash upon Request Preview open #26611
[CP Staging] Fix crash upon Request Preview open #26611
Conversation
@parasharrajat 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] |
@@ -18,7 +18,10 @@ function Image(props) { | |||
const {source, isAuthTokenRequired, session, ...rest} = props; | |||
|
|||
let imageSource = source; | |||
if (typeof source !== 'number' && isAuthTokenRequired) { | |||
if (source && source.uri && typeof source.uri === 'number') { | |||
imageSource = source.uri; |
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.
could you test other Image components used in App to make sure this doesn't break other parts of App? 🙇 🙇 🙇
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.
Yeah, for sure.
Co-authored-by: Rajat Parashar <[email protected]>
@@ -10,7 +10,7 @@ const imagePropTypes = { | |||
source: PropTypes.oneOfType([ | |||
PropTypes.number, | |||
PropTypes.shape({ | |||
uri: PropTypes.string.isRequired, | |||
uri: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, |
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.
isn't the uri should be always string https://reactnative.dev/docs/image#imagesource(I mean aren't we pass a direct number if required instead of wrapping in a object and assigning it to the uri)?
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.
That was done initially but that would have required us managing the different value everywhere Image
is used so I thought why don't we handle this inside Image.
Now you don't have to handle differences between platfroms for local resources. Just use {uri: localpath /resoource ID}
.
Do you have any suggestions?
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.
TBH I don't have any suggestions yet, I just found URI is a string in all places for React doc. Also strange that we are using the same pattern earlier and didn't face this issue for android. I will update in case I find something.
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.
This will break source prop in other places also.
Please look into this urgently.
cc @parasharrajat
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.
You should rather modify the ReceiptUtils.getThumbnailAndImageURIs function ig.
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.
this image passes to ReportActionItemImage
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.
Oh, I see. The resolution of this problem is more straightforward than anticipated.
@pradeepmdk @parasharrajat Allow me to fix this in #26452
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.
ya because #26452 you are splitting the sourcePropTypes here. so we need to update to allow numbers on native.js.
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.
IMO, it is not a bug deal. Image
is a custom component and it is always better to keep the same prop format. I would prefer if we were just able to use {uri: anything}
on all platforms. Less confusing.
I was going to suggest limiting the prop format to this only but that requires a bigger refactor which is unrelated to both problems we are solving(this & #26452). In short, no passing of direct require reference.
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.
@parasharrajat I also prefer this.
@parasharrajat @ZhenjaHorbach can either of you complete the checklist please? |
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop.moviOSios.movAndroidandroid.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.
source.uri : number
filename: undefined
Reproduced these on all platforms and confirmed no crash
Requesting CP now... requested |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
[CP Staging] Fix crash upon Request Preview open (cherry picked from commit a7dfd6f)
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 1.3.62-4 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.62-4 🚀
|
🚀 Deployed to staging by https://github.com/hayata-suenaga in version: 1.3.64-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.64-2 🚀
|
Details
Fixed Issues
$ #26585
PROPOSAL: #26585 (comment)
Tests
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)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Web
Untitled.mp4
Mobile Web - Chrome
WhatsApp.Video.2023-09-03.at.11.32.44.PM.mp4
Mobile Web - Safari
WhatsApp.Video.2023-09-03.at.11.29.56.PM.mp4
Desktop
Untitled.mp4
iOS
Screen.Recording.2023-09-03.at.11.23.28.PM.mov
Android
Screen.Recording.2023-09-03.at.11.19.32.PM.mov