Scan - No error modal shown after selecting corrupted image.#40162
Scan - No error modal shown after selecting corrupted image.#40162arosiclair merged 6 commits intoExpensify:mainfrom
Conversation
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
|
@paultsimura 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] |
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
| const validateAndCompleteAttachmentSelection = useCallback( | ||
| (fileData: FileResponse) => { | ||
| if (fileData.width === -1 || fileData.height === -1) { | ||
| if (fileData.width === -1 || fileData.height === -1 || (fileData.height === 0 && fileData.width === 0)) { |
There was a problem hiding this comment.
Is this some edge case when fileData.height === 0 && fileData.width === 0?
There was a problem hiding this comment.
Yeah, on ios native the image width/height for corrupted image is 0 and on android native it is -1.
There was a problem hiding this comment.
@paultsimura, you mean you are unable to find corrupted image on ios attachment picker or something else?
There was a problem hiding this comment.
Sorry, I've removed the previous comment – finally figured out how to upload the corrupted image into my simulator
src/libs/fileDownload/FileUtils.ts
Outdated
| function checkIfImageIsCorrupted(file: FileObject) { | ||
| return new Promise((resolve, reject) => { | ||
| if (!Str.isImage(file.name ?? '')) { | ||
| resolve(true); | ||
| } | ||
| ImageSize.getSize(file.uri ?? '') | ||
| .then(() => { | ||
| resolve(true); | ||
| }) | ||
| .catch(() => { | ||
| reject(new Error(`'Error reading file: The file is corrupted`)); | ||
| }); | ||
| }); | ||
| } |
There was a problem hiding this comment.
Let's better go this way:
- Rename the function;
- If the file is not an image – return the
resolveinstead of simply calling it;
| function checkIfImageIsCorrupted(file: FileObject) { | |
| return new Promise((resolve, reject) => { | |
| if (!Str.isImage(file.name ?? '')) { | |
| resolve(true); | |
| } | |
| ImageSize.getSize(file.uri ?? '') | |
| .then(() => { | |
| resolve(true); | |
| }) | |
| .catch(() => { | |
| reject(new Error(`'Error reading file: The file is corrupted`)); | |
| }); | |
| }); | |
| } | |
| function validateImageForCorruption(file: FileObject): Promise<void> { | |
| if (!Str.isImage(file.name ?? '')) { | |
| return Promise.resolve(); | |
| } | |
| return new Promise((resolve, reject) => { | |
| ImageSize.getSize(file.uri ?? '') | |
| .then(() => resolve()) | |
| .catch(() => reject(new Error('Error reading file: The file is corrupted'))); | |
| }); | |
| } |
There was a problem hiding this comment.
Sure, will keep this in mind from next time. I appreciate the tip :)
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid17.29.mp4Android: mWeb Chromechrome11.09.mp4iOS: NativeSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-04-12.at.17.08.4717.29.mp4iOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-04-13.at.11.06.5011.09.mp4MacOS: Chrome / SafariScreen.Recording.2024-04-12.at.17.34.4410.57.mp4MacOS: DesktopScreen.Recording.2024-04-13.at.11.00.4211.01.mp4 |
| .catch(() => { | ||
| showImageCorruptionAlert(); | ||
| }); |
There was a problem hiding this comment.
NAB: could you please update this?
| .catch(() => { | |
| showImageCorruptionAlert(); | |
| }); | |
| .catch(() => showImageCorruptionAlert()); |
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
|
Hi, I noticed that recently I am not able to scan correct pdf file and I believe its related to that PR 1.mp42.mp4 |
|
@kubabutkiewicz, thanks a lot for the heads up. I'll check this ASAP. |
|
🚀 Deployed to staging by https://github.com/arosiclair in version: 1.4.63-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.63-21 🚀
|

Details
Fixed Issues
$ #37435
PROPOSAL: #37435 (comment)
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