Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] fix: Distance - App crashes when tapping on the receipt thumbnail while receipt is generating #28852

Merged
merged 2 commits into from
Oct 4, 2023
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
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
Loading