From 688b129b974cbd4da52725565c70c282bd4b2097 Mon Sep 17 00:00:00 2001 From: Pavlo Tsimura Date: Wed, 4 Oct 2023 21:22:39 +0200 Subject: [PATCH 1/2] Handle numeric representation of static images on native --- src/components/Attachments/AttachmentView/index.js | 9 +++++---- src/components/Attachments/propTypes.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) 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 ( Date: Wed, 4 Oct 2023 23:02:51 +0200 Subject: [PATCH 2/2] Change source-related comments to include numeric format --- .../AttachmentCarousel/Pager/AttachmentCarouselPage.js | 2 +- src/components/Attachments/AttachmentView/propTypes.js | 4 ++-- src/components/Attachments/propTypes.js | 4 ++-- 3 files changed, 5 insertions(+), 5 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/propTypes.js b/src/components/Attachments/AttachmentView/propTypes.js index c9f42861fb54..2d4acdda0c1f 100644 --- a/src/components/Attachments/AttachmentView/propTypes.js +++ b/src/components/Attachments/AttachmentView/propTypes.js @@ -5,10 +5,10 @@ const attachmentViewPropTypes = { /** 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, - /** File object maybe be instance of File or Object */ + /** File object can be an instance of File or Object */ file: AttachmentsPropTypes.attachmentFilePropType, /** Whether this view is the active screen */ diff --git a/src/components/Attachments/propTypes.js b/src/components/Attachments/propTypes.js index 97717a1e51da..698a41de9648 100644 --- a/src/components/Attachments/propTypes.js +++ b/src/components/Attachments/propTypes.js @@ -9,10 +9,10 @@ const attachmentPropType = PropTypes.shape({ /** 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: attachmentSourcePropType.isRequired, - /** File object maybe be instance of File or Object */ + /** File object can be an instance of File or Object */ file: attachmentFilePropType, });