diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 443a553d4689..2578845914fc 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -25,9 +25,7 @@ type BaseAnchorForAttachmentsOnlyProps = AnchorForAttachmentsOnlyProps & { function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onPressIn, onPressOut}: BaseAnchorForAttachmentsOnlyProps) { const sourceURLWithAuth = addEncryptedAuthTokenToURL(source); const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; - const [download] = useOnyx(`${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`); - const {isOffline} = useNetwork(); const styles = useThemeStyles(); @@ -37,7 +35,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive, isDisabled}) => ( { if (isDownloading || isOffline || !sourceID) { return; @@ -63,7 +61,6 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP shouldShowDownloadIcon={!!sourceID && !isOffline} shouldShowLoadingSpinnerIcon={isDownloading} isUsedAsChatAttachment - isUploading={!sourceID} /> )} diff --git a/src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx b/src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx index e6ac9f9f21c7..ee594f66aabc 100644 --- a/src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx +++ b/src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx @@ -24,12 +24,9 @@ type DefaultAttachmentViewProps = { containerStyles?: StyleProp; icon?: IconAsset; - - /** Flag indicating if the attachment is being uploaded. */ - isUploading?: boolean; }; -function DefaultAttachmentView({fileName = '', shouldShowLoadingSpinnerIcon = false, shouldShowDownloadIcon, containerStyles, icon, isUploading}: DefaultAttachmentViewProps) { +function DefaultAttachmentView({fileName = '', shouldShowLoadingSpinnerIcon = false, shouldShowDownloadIcon, containerStyles, icon}: DefaultAttachmentViewProps) { const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -56,7 +53,7 @@ function DefaultAttachmentView({fileName = '', shouldShowLoadingSpinnerIcon = fa )} {shouldShowLoadingSpinnerIcon && ( - + ; +}; - /** Function for handle on press */ - onPress?: (e?: GestureResponderEvent | KeyboardEvent) => void; +type AttachmentViewProps = AttachmentViewOnyxProps & + Attachment & { + /** Whether this view is the active screen */ + isFocused?: boolean; - /** Whether the attachment is used in attachment modal */ - isUsedInAttachmentModal?: boolean; + /** Function for handle on press */ + onPress?: (e?: GestureResponderEvent | KeyboardEvent) => void; - /** Flag to show/hide download icon */ - shouldShowDownloadIcon?: boolean; + isUsedInAttachmentModal?: boolean; - /** Flag to show the loading indicator */ - shouldShowLoadingSpinnerIcon?: boolean; + /** Flag to show/hide download icon */ + shouldShowDownloadIcon?: boolean; - /** Notify parent that the UI should be modified to accommodate keyboard */ - onToggleKeyboard?: (shouldFadeOut: boolean) => void; + /** Flag to show the loading indicator */ + shouldShowLoadingSpinnerIcon?: boolean; - /** A callback when the PDF fails to load */ - onPDFLoadError?: () => void; + /** Notify parent that the UI should be modified to accommodate keyboard */ + onToggleKeyboard?: (shouldFadeOut: boolean) => void; - /** Extra styles to pass to View wrapper */ - containerStyles?: StyleProp; + /** A callback when the PDF fails to load */ + onPDFLoadError?: () => void; - /** Denotes whether it is a workspace avatar or not */ - isWorkspaceAvatar?: boolean; + /** Extra styles to pass to View wrapper */ + containerStyles?: StyleProp; - /** Denotes whether it is an icon (ex: SVG) */ - maybeIcon?: boolean; + /** Denotes whether it is a workspace avatar or not */ + isWorkspaceAvatar?: boolean; - /** Fallback source to use in case of error */ - fallbackSource?: AttachmentSource; + /** Denotes whether it is an icon (ex: SVG) */ + maybeIcon?: boolean; - /* Whether it is hovered or not */ - isHovered?: boolean; + /** Fallback source to use in case of error */ + fallbackSource?: AttachmentSource; - /** Whether the attachment is used as a chat attachment */ - isUsedAsChatAttachment?: boolean; + /* Whether it is hovered or not */ + isHovered?: boolean; - /* Flag indicating whether the attachment has been uploaded. */ - isUploaded?: boolean; + /** Whether the attachment is used as a chat attachment */ + isUsedAsChatAttachment?: boolean; - /** Flag indicating if the attachment is being uploaded. */ - isUploading?: boolean; -}; + /* Flag indicating whether the attachment has been uploaded. */ + isUploaded?: boolean; + }; function AttachmentView({ source, @@ -92,20 +95,16 @@ function AttachmentView({ isWorkspaceAvatar, maybeIcon, fallbackSource, - transactionID = '-1', + transaction, reportActionID, isHovered, duration, isUsedAsChatAttachment, isUploaded = true, - isUploading = false, }: AttachmentViewProps) { const {translate} = useLocalize(); const {updateCurrentlyPlayingURL} = usePlaybackContext(); const attachmentCarouselPagerContext = useContext(AttachmentCarouselPagerContext); - - const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`); - const theme = useTheme(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -289,16 +288,20 @@ function AttachmentView({ ); } AttachmentView.displayName = 'AttachmentView'; -export default memo(AttachmentView); +export default memo( + withOnyx({ + transaction: { + key: ({transactionID}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, + }, + })(AttachmentView), +); export type {AttachmentViewProps}; diff --git a/src/languages/en.ts b/src/languages/en.ts index 924e2f009942..98896bc70799 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -276,7 +276,6 @@ const translations = { close: 'Close', download: 'Download', downloading: 'Downloading', - uploading: 'Uploading', pin: 'Pin', unPin: 'Unpin', back: 'Back', diff --git a/src/languages/es.ts b/src/languages/es.ts index 8a9d138b2482..31977839a596 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -266,7 +266,6 @@ const translations = { close: 'Cerrar', download: 'Descargar', downloading: 'Descargando', - uploading: 'Subiendo', pin: 'Fijar', unPin: 'Desfijar', back: 'Volver',