Skip to content
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
5 changes: 5 additions & 0 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ type AttachmentModalProps = AttachmentModalOnyxProps & {
/** Denotes whether it is a workspace avatar or not */
isWorkspaceAvatar?: boolean;

/** Denotes whether it can be an icon (ex: SVG) */
maybeIcon?: boolean;

/** Whether it is a receipt attachment or not */
isReceiptAttachment?: boolean;

Expand All @@ -154,6 +157,7 @@ function AttachmentModal({
onCarouselAttachmentChange = () => {},
isReceiptAttachment = false,
isWorkspaceAvatar = false,
maybeIcon = false,
transaction,
parentReport,
parentReportActions,
Expand Down Expand Up @@ -531,6 +535,7 @@ function AttachmentModal({
file={file}
onToggleKeyboard={updateConfirmButtonVisibility}
isWorkspaceAvatar={isWorkspaceAvatar}
maybeIcon={maybeIcon}
fallbackSource={fallbackSource}
isUsedInAttachmentModal
transactionID={transaction?.transactionID}
Expand Down
10 changes: 8 additions & 2 deletions src/components/Attachments/AttachmentView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const propTypes = {
/** Denotes whether it is a workspace avatar or not */
isWorkspaceAvatar: PropTypes.bool,

/** Denotes whether it is an icon (ex: SVG) */
maybeIcon: PropTypes.bool,

/** The id of the transaction related to the attachment */
// eslint-disable-next-line react/no-unused-prop-types
transactionID: PropTypes.string,
Expand All @@ -60,6 +63,7 @@ const defaultProps = {
onToggleKeyboard: () => {},
containerStyles: [],
isWorkspaceAvatar: false,
maybeIcon: false,
transactionID: '',
};

Expand All @@ -80,6 +84,7 @@ function AttachmentView({
carouselActiveItemIndex,
isUsedInAttachmentModal,
isWorkspaceAvatar,
maybeIcon,
fallbackSource,
transaction,
}) {
Expand All @@ -91,8 +96,9 @@ function AttachmentView({

useNetwork({onReconnect: () => setImageError(false)});

// Handles case where source is a component (ex: SVG)
if (_.isFunction(source)) {
// Handles case where source is a component (ex: SVG) or a number
// Number may represent a SVG or an image
if ((maybeIcon && typeof source === 'number') || _.isFunction(source)) {
let iconFillColor = '';
let additionalStyles = [];
if (isWorkspaceAvatar) {
Expand Down
1 change: 1 addition & 0 deletions src/components/AvatarWithImagePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ function AvatarWithImagePicker({
source={previewSource}
originalFileName={originalFileName}
fallbackSource={fallbackIcon}
maybeIcon={isUsingDefaultAvatar}
>
{({show}) => (
<AttachmentPicker type={CONST.ATTACHMENT_PICKER_TYPE.IMAGE}>
Expand Down
1 change: 1 addition & 0 deletions src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function DetailsPage(props) {
source={UserUtils.getFullSizeAvatar(details.avatar, details.accountID)}
isAuthTokenRequired
originalFileName={details.originalFileName}
maybeIcon
>
{({show}) => (
<PressableWithoutFocus
Expand Down
1 change: 1 addition & 0 deletions src/pages/ReportAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function ReportAvatar({report = {} as Report, policies, isLoadingApp = true}: Re
Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID ?? ''));
}}
isWorkspaceAvatar
maybeIcon
originalFileName={policy?.originalFileName ?? policyName}
shouldShowNotFoundPage={!report?.reportID && !isLoadingApp}
isLoading={(!report?.reportID || !policy?.id) && !!isLoadingApp}
Expand Down