From db9906778ab93624844f30e8771adcc2150f4fd0 Mon Sep 17 00:00:00 2001 From: Vit Horacek <36083550+mountiny@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:37:25 +0100 Subject: [PATCH] Merge pull request #28852 from paultsimura/fix/28814-ios-receipt [CP Staging] fix: Distance - App crashes when tapping on the receipt thumbnail while receipt is generating (cherry picked from commit b620fdee82551aaaec2fa32812fd9439b5f15d4a) --- .../AttachmentCarousel/Pager/AttachmentCarouselPage.js | 2 +- src/components/Attachments/AttachmentView/index.js | 9 +++++---- src/components/Attachments/AttachmentView/propTypes.js | 4 ++-- src/components/Attachments/propTypes.js | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js b/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js index f7da8cfce894..580c7eaac732 100644 --- a/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js +++ b/src/components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPage.js @@ -21,7 +21,7 @@ const pagePropTypes = { /** Whether source url requires authentication */ isAuthTokenRequired: PropTypes.bool, - /** URL to full-sized attachment or SVG function */ + /** URL to full-sized attachment, SVG function, or numeric static image on native platforms */ source: AttachmentsPropTypes.attachmentSourcePropType.isRequired, isActive: PropTypes.bool.isRequired, diff --git a/src/components/Attachments/AttachmentView/index.js b/src/components/Attachments/AttachmentView/index.js index 1fc579977c9d..f4d3036ff802 100755 --- a/src/components/Attachments/AttachmentView/index.js +++ b/src/components/Attachments/AttachmentView/index.js @@ -92,9 +92,9 @@ function AttachmentView({ ); } - // Check both source and file.name since PDFs dragged into the the text field + // Check both source and file.name since PDFs dragged into the text field // will appear with a source that is a blob - if (Str.isPDF(source) || (file && Str.isPDF(file.name || translate('attachmentView.unknownFilename')))) { + if ((_.isString(source) && Str.isPDF(source)) || (file && Str.isPDF(file.name || translate('attachmentView.unknownFilename')))) { const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source) : source; return ( @@ -114,8 +114,9 @@ function AttachmentView({ } // For this check we use both source and file.name since temporary file source is a blob - // both PDFs and images will appear as images when pasted into the the text field - const isImage = Str.isImage(source); + // both PDFs and images will appear as images when pasted into the text field. + // We also check for numeric source since this is how static images (used for preview) are represented in RN. + const isImage = typeof source === 'number' || Str.isImage(source); if (isImage || (file && Str.isImage(file.name))) { return (