Skip to content
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

Load generic receipt thumbnail for other file formats #25969

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libs/ReceiptUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ function validateReceipt(file) {
* @returns {Object}
*/
function getThumbnailAndImageURIs(path, filename) {
const isReceiptImage = Str.isImage(filename);

// For local files, we won't have a thumbnail yet
if (path.startsWith('blob:') || path.startsWith('file:')) {
if (isReceiptImage && (path.startsWith('blob:') || path.startsWith('file:'))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logically, the && has higher precedence here, meaning this applies for images that start with blob: or any other file, right? I'm not sure if that's the intended behavior or if what we want is any image that starts with blob: or file: to return here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should apply for receipts that are image AND start with blob or file, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, this applies for images that start with "blob", or anything that starts with "file".

Screenshot 2023-08-28 at 17 26 10

I think what you might want is image && (blob || file), but I'm not actually sure because I'm don't really understand the fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, isn't image && (blob || file) what I have here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I misread this. It definitely looks like this now.

return {thumbnail: null, image: path};
}

const {fileExtension} = FileUtils.splitExtensionFromFileName(filename);
const isReceiptImage = Str.isImage(filename);

if (isReceiptImage) {
return {thumbnail: `${path}.1024.jpg`, image: path};
}

const {fileExtension} = FileUtils.splitExtensionFromFileName(filename);
let image = ReceiptGeneric;
if (fileExtension === CONST.IOU.FILE_TYPES.HTML) {
image = ReceiptHTML;
Expand Down
Loading