-
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
Merged
hayata-suenaga
merged 9 commits into
Expensify:main
from
pradeepmdk:fix/26585-uri-should-be-string
Sep 4, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d34bae4
uri type case check
pradeepmdk 775ecc3
allow local image
pradeepmdk f337d11
fix the lint issue
pradeepmdk 2605b0a
prettier fix
pradeepmdk b983476
update the condition
pradeepmdk fdff8ee
update preitter
pradeepmdk b7728d4
Update src/components/ReportActionItem/ReportActionItemImage.js
pradeepmdk ad1608d
update props
pradeepmdk 13dd7b1
filename check
pradeepmdk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') { | ||
pradeepmdk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
imageSource = source.uri; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, for sure. |
||
} | ||
if (typeof imageSource !== 'number' && isAuthTokenRequired) { | ||
const authToken = lodashGet(props, 'session.encryptedAuthToken', null); | ||
imageSource = { | ||
...source, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.