fix: wrong attachment corrupt alert for pdf.#40351
fix: wrong attachment corrupt alert for pdf.#40351arosiclair merged 2 commits intoExpensify:mainfrom
Conversation
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
|
@francoisl 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] |
|
@francoisl sorry for the ping :( cc: @paultsimura |
|
@Krishna2323 could you please explain this change a little? What specifically caused the issue with PDF? |
| // The width/height for corrupt file is -1 on android native and 0 on ios native | ||
| if (width <= 0 || height <= 0) { | ||
| throw new Error('Image dimensions are invalid.'); | ||
| } |
There was a problem hiding this comment.
| // The width/height for corrupt file is -1 on android native and 0 on ios native | |
| if (width <= 0 || height <= 0) { | |
| throw new Error('Image dimensions are invalid.'); | |
| } |
| // Check if the file dimensions indicate corruption | ||
| // The width/height for corrupt file is -1 on android native and 0 on ios native | ||
| if (!fileData.width || !fileData.height || (fileData.width <= 0 && fileData.height <= 0)) { | ||
| if (fileData.width === -1 || fileData.height === -1) { |
There was a problem hiding this comment.
Can't we go this way instead?
// Check if the file dimensions indicate corruption
// The width/height for a corrupted file is -1 on android native and 0 on ios native
// We must check only numeric values because the width/height can be undefined for non-image files
if (typeof fileData.width === 'number' && fileData.width <= 0 || typeof fileData.height === 'number' && fileData.height <= 0) {
showImageCorruptionAlert();
return Promise.resolve();
}There was a problem hiding this comment.
Yes, this will also work.
There was a problem hiding this comment.
I think it's better because we'll keep validating the dimensions in one place. Please update
|
This function also runs for non-image files, and width/height is undefined in that case. App/src/components/AttachmentPicker/index.native.tsx Lines 238 to 245 in 553e54f |
|
Also, please fill in the checklist |
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid00.06.mp4Android: mWeb ChromeiOS: NativeSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-04-17.at.23.23.5700.06.mp4iOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-04-18.at.00.09.0100.09.mp4MacOS: Chrome / SafariScreen.Recording.2024-04-18.at.00.04.2500.06.mp4MacOS: DesktopScreen.Recording.2024-04-18.at.00.06.1400.06.mp4 |
|
@Krishna2323 please put #37435 under the fixed issues instead of the PR link you've added. |
|
🎯 @paultsimura, thanks for reviewing and testing this PR! 🎉 An E/App issue has been created to issue payment here: #40384. |
|
@arosiclair this is a follow-up of #40162. Please review when you have a minute 🙇 |
|
✋ 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 production by https://github.com/mountiny in version: 1.4.64-6 🚀
|
Details
Fixed Issues
$ #37435
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android_native.mp4
Android: mWeb Chrome
android_chrome.mp4
iOS: Native
ios_native.mp4
iOS: mWeb Safari
ios_safari.mp4
MacOS: Chrome / Safari
web_chrome.mp4
MacOS: Desktop
desktop_app.mp4