Skip to content

Commit

Permalink
Merge pull request #28852 from paultsimura/fix/28814-ios-receipt
Browse files Browse the repository at this point in the history
[CP Staging] fix: Distance - App crashes when tapping on the receipt thumbnail while receipt is generating

(cherry picked from commit b620fde)
  • Loading branch information
mountiny authored and OSBotify committed Oct 4, 2023
1 parent 206a2ae commit db99067
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/components/Attachments/AttachmentView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 (
<AttachmentViewImage
Expand Down
4 changes: 2 additions & 2 deletions src/components/Attachments/AttachmentView/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 3 additions & 3 deletions src/components/Attachments/propTypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';

const attachmentSourcePropType = PropTypes.oneOfType([PropTypes.string, PropTypes.func]);
const attachmentSourcePropType = PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.number]);
const attachmentFilePropType = PropTypes.shape({
name: PropTypes.string,
});
Expand All @@ -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,
});

Expand Down

0 comments on commit db99067

Please sign in to comment.