diff --git a/src/components/ImageView/index.js b/src/components/ImageView/index.js index 6fa8737cfbcd..09656d700917 100644 --- a/src/components/ImageView/index.js +++ b/src/components/ImageView/index.js @@ -5,7 +5,6 @@ import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import Image from '@components/Image'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as FileUtils from '@libs/fileDownload/FileUtils'; import styles from '@styles/styles'; import * as StyleUtils from '@styles/StyleUtils'; import CONST from '@src/CONST'; @@ -22,7 +21,7 @@ const propTypes = { url: PropTypes.string.isRequired, /** image file name */ - fileName: PropTypes.string, + fileName: PropTypes.string.isRequired, onError: PropTypes.func, }; @@ -30,7 +29,6 @@ const propTypes = { const defaultProps = { isAuthTokenRequired: false, onError: () => {}, - fileName: '', }; function ImageView({isAuthTokenRequired, url, fileName, onError}) { @@ -51,7 +49,6 @@ function ImageView({isAuthTokenRequired, url, fileName, onError}) { const scrollableRef = useRef(null); const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); - const accessibilityLabel = fileName || FileUtils.getAttachmentName(url); /** * @param {Number} newContainerWidth @@ -266,7 +263,7 @@ function ImageView({isAuthTokenRequired, url, fileName, onError}) { onPressIn={onContainerPressIn} onPress={onContainerPress} accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGE} - accessibilityLabel={accessibilityLabel} + accessibilityLabel={fileName} > } */ function handleDownload(url, fileName) { @@ -41,7 +41,7 @@ function handleDownload(url, fileName) { // Android files will download to Download directory const path = dirs.DownloadDir; - const attachmentName = fileName ? FileUtils.appendTimeToFileName(fileName) : FileUtils.getAttachmentName(url); + const attachmentName = FileUtils.appendTimeToFileName(fileName) || FileUtils.getAttachmentName(url); const isLocalFile = url.startsWith('file://'); @@ -96,7 +96,7 @@ function handleDownload(url, fileName) { /** * Checks permission and downloads the file for Android * @param {String} url - * @param {String} [fileName] + * @param {String} fileName * @returns {Promise} */ export default function fileDownload(url, fileName) { diff --git a/src/libs/fileDownload/index.ios.js b/src/libs/fileDownload/index.ios.js index 252c40797e7a..1599e919d28a 100644 --- a/src/libs/fileDownload/index.ios.js +++ b/src/libs/fileDownload/index.ios.js @@ -68,14 +68,14 @@ function downloadVideo(fileUrl, fileName) { /** * Download the file based on type(image, video, other file types)for iOS * @param {String} fileUrl - * @param {String} [fileName] + * @param {String} fileName * @returns {Promise} */ export default function fileDownload(fileUrl, fileName) { return new Promise((resolve) => { let fileDownloadPromise = null; const fileType = FileUtils.getFileType(fileUrl); - const attachmentName = fileName ? FileUtils.appendTimeToFileName(fileName) : FileUtils.getAttachmentName(fileUrl); + const attachmentName = FileUtils.appendTimeToFileName(fileName) || FileUtils.getAttachmentName(fileUrl); switch (fileType) { case CONST.ATTACHMENT_FILE_TYPE.IMAGE: diff --git a/src/libs/fileDownload/index.js b/src/libs/fileDownload/index.js index 48309377df81..d1fa968b665f 100644 --- a/src/libs/fileDownload/index.js +++ b/src/libs/fileDownload/index.js @@ -6,7 +6,7 @@ import * as FileUtils from './FileUtils'; /** * Downloading attachment in web, desktop * @param {String} url - * @param {String} [fileName] + * @param {String} fileName * @returns {Promise} */ export default function fileDownload(url, fileName) { @@ -33,7 +33,7 @@ export default function fileDownload(url, fileName) { link.style.display = 'none'; link.setAttribute( 'download', - fileName ? FileUtils.appendTimeToFileName(fileName) : FileUtils.getAttachmentName(url), // generating the file name + FileUtils.appendTimeToFileName(fileName) || FileUtils.getAttachmentName(url), // generating the file name ); // Append to html link element page