Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/components/ReportActionItem/MoneyRequestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ function MoneyRequestView({report, betas, parentReport, policyCategories, should
<ReportActionItemImage
thumbnail={receiptURIs.thumbnail}
image={receiptURIs.image}
isLocalFile={receiptURIs.isLocalFile}
transaction={transaction}
enablePreviewModal
/>
Expand Down
12 changes: 8 additions & 4 deletions src/components/ReportActionItem/ReportActionItemImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import ROUTES from '@src/ROUTES';

const propTypes = {
/** thumbnail URI for the image */
thumbnail: PropTypes.string,
thumbnail: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

/** URI for the image or local numeric reference for the image */
image: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
Expand All @@ -28,12 +28,16 @@ const propTypes = {

/* The transaction associated with this image, if any. Passed for handling eReceipts. */
transaction: transactionPropTypes,

/** whether thumbnail is refer the local file or not */
isLocalFile: PropTypes.bool,
};

const defaultProps = {
thumbnail: null,
transaction: {},
enablePreviewModal: false,
isLocalFile: false,
};

/**
Expand All @@ -42,7 +46,7 @@ const defaultProps = {
* and optional preview modal as well.
*/

function ReportActionItemImage({thumbnail, image, enablePreviewModal, transaction}) {
function ReportActionItemImage({thumbnail, image, enablePreviewModal, transaction, isLocalFile}) {
const {translate} = useLocalize();
const imageSource = tryResolveUrlFromApiRoot(image || '');
const thumbnailSource = tryResolveUrlFromApiRoot(thumbnail || '');
Expand All @@ -56,7 +60,7 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal, transactio
<EReceiptThumbnail transactionID={transaction.transactionID} />
</View>
);
} else if (thumbnail) {
} else if (thumbnail && !isLocalFile) {
receiptImageComponent = (
<ThumbnailImage
previewSourceURL={thumbnailSource}
Expand All @@ -68,7 +72,7 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal, transactio
} else {
receiptImageComponent = (
<Image
source={{uri: image}}
source={{uri: thumbnail || image}}
style={[styles.w100, styles.h100]}
/>
);
Expand Down
5 changes: 3 additions & 2 deletions src/components/ReportActionItem/ReportActionItemImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const propTypes = {
/** array of image and thumbnail URIs */
images: PropTypes.arrayOf(
PropTypes.shape({
thumbnail: PropTypes.string,
thumbnail: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
image: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
transaction: transactionPropTypes,
}),
Expand Down Expand Up @@ -74,7 +74,7 @@ function ReportActionItemImages({images, size, total, isHovered}) {

return (
<View style={[styles.reportActionItemImages, hoverStyle, heightStyle]}>
{_.map(shownImages, ({thumbnail, image, transaction}, index) => {
{_.map(shownImages, ({thumbnail, image, transaction, isLocalFile}, index) => {
const isLastImage = index === numberOfShownImages - 1;

// Show a border to separate multiple images. Shown to the right for each except the last.
Expand All @@ -88,6 +88,7 @@ function ReportActionItemImages({images, size, total, isHovered}) {
<ReportActionItemImage
thumbnail={thumbnail}
image={image}
isLocalFile={isLocalFile}
transaction={transaction}
/>
{isLastImage && remaining > 0 && (
Expand Down
5 changes: 3 additions & 2 deletions src/libs/ReceiptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import * as FileUtils from './fileDownload/FileUtils';

type ThumbnailAndImageURI = {
image: ImageSourcePropType | string;
thumbnail: string | null;
thumbnail: ImageSourcePropType | string | null;
transaction?: Transaction;
isLocalFile?: boolean;
};

type FileNameAndExtension = {
Expand Down Expand Up @@ -65,7 +66,7 @@ function getThumbnailAndImageURIs(transaction: Transaction, receiptPath: string
image = ReceiptSVG;
}

return {thumbnail: null, image};
return {thumbnail: image, image: path, isLocalFile: true};
Copy link
Contributor

Choose a reason for hiding this comment

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

You forgot to cover the case of local files which caused a bug. More details here: #33474

}

// eslint-disable-next-line import/prefer-default-export
Expand Down