-
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
Scan - No error modal shown after selecting corrupted image. #40162
Scan - No error modal shown after selecting corrupted image. #40162
Conversation
Signed-off-by: Krishna Gupta <[email protected]>
@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] |
@@ -237,7 +237,7 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this some edge case when fileData.height === 0 && fileData.width === 0
?
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, 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paultsimura, you mean you are unable to find corrupted image on ios attachment picker or something else?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's better go this way:
- Rename the function;
- If the file is not an image – return the
resolve
instead 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
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.
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.
Sure, will keep this in mind from next time. I appreciate the tip :)
Signed-off-by: Krishna Gupta <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB: could you please update this?
.catch(() => { | |
showImageCorruptionAlert(); | |
}); | |
.catch(() => showImageCorruptionAlert()); |
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 ✔️
Signed-off-by: Krishna Gupta <[email protected]>
Signed-off-by: Krishna Gupta <[email protected]>
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.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 and/or tagged@Expensify/design
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_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