From 49895f613b679f7ae85b24d2c9385eea3ad3b502 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 1 Feb 2024 11:11:28 +0700 Subject: [PATCH 1/2] fix: Invalid file is downloaded when uploading invalid file and downloading from receipt view --- src/components/ReportActionItem/MoneyRequestView.js | 1 + .../ReportActionItem/ReportActionItemImage.tsx | 7 +++++-- src/libs/ReceiptUtils.ts | 9 +++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index e03dd6e4744c..275d2a6da74c 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -247,6 +247,7 @@ function MoneyRequestView({report, parentReport, parentReportActions, policyCate thumbnail={receiptURIs.thumbnail} image={receiptURIs.image} isLocalFile={receiptURIs.isLocalFile} + filename={receiptURIs.filename || transaction.filename} transaction={transaction} enablePreviewModal canEditReceipt={canEditReceipt} diff --git a/src/components/ReportActionItem/ReportActionItemImage.tsx b/src/components/ReportActionItem/ReportActionItemImage.tsx index e71eb6834cc7..d1fc72767f56 100644 --- a/src/components/ReportActionItem/ReportActionItemImage.tsx +++ b/src/components/ReportActionItem/ReportActionItemImage.tsx @@ -34,6 +34,9 @@ type ReportActionItemImageProps = { /** whether the receipt can be replaced */ canEditReceipt?: boolean; + + /** Filename of attachment */ + filename?: string; }; /** @@ -42,7 +45,7 @@ type ReportActionItemImageProps = { * and optional preview modal as well. */ -function ReportActionItemImage({thumbnail, image, enablePreviewModal = false, transaction, canEditReceipt = false, isLocalFile = false}: ReportActionItemImageProps) { +function ReportActionItemImage({thumbnail, image, enablePreviewModal = false, transaction, canEditReceipt = false, isLocalFile = false, filename}: ReportActionItemImageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const imageSource = tryResolveUrlFromApiRoot(image ?? ''); @@ -86,7 +89,7 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal = false, tr isReceiptAttachment canEditReceipt={canEditReceipt} allowDownload - originalFileName={transaction?.filename} + originalFileName={filename} > {({show}) => ( Date: Fri, 2 Feb 2024 15:39:43 +0700 Subject: [PATCH 2/2] remove fallback value --- src/components/ReportActionItem/MoneyRequestView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 275d2a6da74c..5632d3c22e7d 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -247,7 +247,7 @@ function MoneyRequestView({report, parentReport, parentReportActions, policyCate thumbnail={receiptURIs.thumbnail} image={receiptURIs.image} isLocalFile={receiptURIs.isLocalFile} - filename={receiptURIs.filename || transaction.filename} + filename={receiptURIs.filename} transaction={transaction} enablePreviewModal canEditReceipt={canEditReceipt}