diff --git a/src/CONST/index.ts b/src/CONST/index.ts index f774ac541d87e..ea6ae81763033 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1861,7 +1861,6 @@ const CONST = { MSWORD: 'application/msword', ZIP: 'application/zip', RFC822: 'message/rfc822', - HEIC: 'image/heic', }, SHARE_FILE_MIMETYPE: { @@ -1872,7 +1871,6 @@ const CONST = { WEBP: 'image/webp', TIF: 'image/tif', TIFF: 'image/tiff', - HEIC: 'image/heic', IMG: 'image/*', PDF: 'application/pdf', MSWORD: 'application/msword', diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 808e2781a7fea..9781b4ea3ac7e 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -2,7 +2,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect, useMemo, useState} from 'react'; import {SafeAreaView, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import type {FileObject} from '@components/AttachmentModal'; import AttachmentModal from '@components/AttachmentModal'; import AttachmentPreview from '@components/AttachmentPreview'; import Button from '@components/Button'; @@ -14,7 +13,6 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; -import useFilesValidation from '@hooks/useFilesValidation'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -55,20 +53,9 @@ function ShareDetailsPage({ const [errorTitle, setErrorTitle] = useState(undefined); const [errorMessage, setErrorMessage] = useState(undefined); - const [validFilesToUpload, setValidFilesToUpload] = useState([]); - const {validateFiles} = useFilesValidation(setValidFilesToUpload); - const report: OnyxEntry = getReportOrDraftReport(reportOrAccountID); const displayReport = useMemo(() => getReportDisplayOption(report, unknownUserDetails, reportAttributesDerived), [report, unknownUserDetails, reportAttributesDerived]); - useEffect(() => { - if (!currentAttachment || isTextShared || validFilesToUpload.length !== 0) { - return; - } - - validateFiles([{name: currentAttachment.id, uri: currentAttachment.content, type: currentAttachment.mimeType}]); - }, [currentAttachment, isTextShared, validFilesToUpload.length, validateFiles]); - useEffect(() => { if (!currentAttachment?.content || errorTitle) { return; @@ -105,7 +92,7 @@ function ShareDetailsPage({ const fileName = currentAttachment?.content.split('/').pop(); const handleShare = () => { - if (!currentAttachment || validFilesToUpload.length === 0) { + if (!currentAttachment) { return; } @@ -116,10 +103,9 @@ function ShareDetailsPage({ return; } - const validatedFile = validFilesToUpload.at(0); readFileAsync( - validatedFile?.uri ?? '', - getFileName(validatedFile?.uri ?? 'shared_image.png'), + currentAttachment.content, + getFileName(currentAttachment.content), (file) => { if (isDraft) { openReport( @@ -140,7 +126,7 @@ function ShareDetailsPage({ Navigation.navigate(routeToNavigate, {forceReplace: true}); }, () => {}, - validatedFile?.type ?? 'image/jpeg', + currentAttachment.mimeType, ); }; @@ -211,13 +197,13 @@ function ShareDetailsPage({ {({show}) => ( { diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index efb50bd65f738..5792da27cc4ca 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -2,14 +2,12 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect, useState} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import type {FileObject} from '@components/AttachmentModal'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import LocationPermissionModal from '@components/LocationPermissionModal'; import MoneyRequestConfirmationList from '@components/MoneyRequestConfirmationList'; import ScreenWrapper from '@components/ScreenWrapper'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; -import useFilesValidation from '@hooks/useFilesValidation'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; @@ -62,17 +60,6 @@ function SubmitDetailsPage({ const {isBetaEnabled} = usePermissions(); const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS); - const [validFilesToUpload, setValidFilesToUpload] = useState([]); - const {validateFiles} = useFilesValidation(setValidFilesToUpload); - - useEffect(() => { - if (!currentAttachment || validFilesToUpload.length !== 0) { - return; - } - - validateFiles([{name: currentAttachment.id, uri: currentAttachment.content, type: currentAttachment.mimeType}]); - }, [currentAttachment, validFilesToUpload.length, validateFiles]); - useEffect(() => { if (!errorTitle || !errorMessage) { return; @@ -204,13 +191,12 @@ function SubmitDetailsPage({ return; } - const validatedFile = validFilesToUpload.at(0); readFileAsync( - validatedFile?.uri ?? '', - getFileName(validatedFile?.name ?? 'shared_image.png'), + currentAttachment?.content ?? '', + getFileName(currentAttachment?.content ?? 'shared_image.png'), (file) => onSuccess(file, shouldStartLocationPermissionFlow), () => {}, - validatedFile?.type ?? 'image/jpeg', + currentAttachment?.mimeType ?? 'image/jpeg', ); }; @@ -241,8 +227,8 @@ function SubmitDetailsPage({ iouComment={trimmedComment} iouCategory={transaction?.category} onConfirm={() => onConfirm(true)} - receiptPath={validFilesToUpload.at(0)?.uri} - receiptFilename={getFileName(validFilesToUpload.at(0)?.name ?? '')} + receiptPath={currentAttachment?.content} + receiptFilename={getFileName(currentAttachment?.content ?? '')} reportID={reportOrAccountID} shouldShowSmartScanFields={false} isDistanceRequest={false}