Skip to content

Commit 7771086

Browse files
committed
1 parent bb3a5ba commit 7771086

3 files changed

Lines changed: 11 additions & 41 deletions

File tree

src/CONST/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,6 @@ const CONST = {
18611861
MSWORD: 'application/msword',
18621862
ZIP: 'application/zip',
18631863
RFC822: 'message/rfc822',
1864-
HEIC: 'image/heic',
18651864
},
18661865

18671866
SHARE_FILE_MIMETYPE: {
@@ -1872,7 +1871,6 @@ const CONST = {
18721871
WEBP: 'image/webp',
18731872
TIF: 'image/tif',
18741873
TIFF: 'image/tiff',
1875-
HEIC: 'image/heic',
18761874
IMG: 'image/*',
18771875
PDF: 'application/pdf',
18781876
MSWORD: 'application/msword',

src/pages/Share/ShareDetailsPage.tsx

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type {StackScreenProps} from '@react-navigation/stack';
22
import React, {useEffect, useMemo, useState} from 'react';
33
import {SafeAreaView, View} from 'react-native';
44
import type {OnyxEntry} from 'react-native-onyx';
5-
import type {FileObject} from '@components/AttachmentModal';
65
import AttachmentModal from '@components/AttachmentModal';
76
import AttachmentPreview from '@components/AttachmentPreview';
87
import Button from '@components/Button';
@@ -14,7 +13,6 @@ import ScreenWrapper from '@components/ScreenWrapper';
1413
import ScrollView from '@components/ScrollView';
1514
import Text from '@components/Text';
1615
import TextInput from '@components/TextInput';
17-
import useFilesValidation from '@hooks/useFilesValidation';
1816
import useLocalize from '@hooks/useLocalize';
1917
import useOnyx from '@hooks/useOnyx';
2018
import useThemeStyles from '@hooks/useThemeStyles';
@@ -55,20 +53,9 @@ function ShareDetailsPage({
5553
const [errorTitle, setErrorTitle] = useState<string | undefined>(undefined);
5654
const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);
5755

58-
const [validFilesToUpload, setValidFilesToUpload] = useState<FileObject[]>([]);
59-
const {validateFiles} = useFilesValidation(setValidFilesToUpload);
60-
6156
const report: OnyxEntry<ReportType> = getReportOrDraftReport(reportOrAccountID);
6257
const displayReport = useMemo(() => getReportDisplayOption(report, unknownUserDetails, reportAttributesDerived), [report, unknownUserDetails, reportAttributesDerived]);
6358

64-
useEffect(() => {
65-
if (!currentAttachment || isTextShared || validFilesToUpload.length !== 0) {
66-
return;
67-
}
68-
69-
validateFiles([{name: currentAttachment.id, uri: currentAttachment.content, type: currentAttachment.mimeType}]);
70-
}, [currentAttachment, isTextShared, validFilesToUpload.length, validateFiles]);
71-
7259
useEffect(() => {
7360
if (!currentAttachment?.content || errorTitle) {
7461
return;
@@ -105,7 +92,7 @@ function ShareDetailsPage({
10592
const fileName = currentAttachment?.content.split('/').pop();
10693

10794
const handleShare = () => {
108-
if (!currentAttachment || validFilesToUpload.length === 0) {
95+
if (!currentAttachment) {
10996
return;
11097
}
11198

@@ -116,10 +103,9 @@ function ShareDetailsPage({
116103
return;
117104
}
118105

119-
const validatedFile = validFilesToUpload.at(0);
120106
readFileAsync(
121-
validatedFile?.uri ?? '',
122-
getFileName(validatedFile?.uri ?? 'shared_image.png'),
107+
currentAttachment.content,
108+
getFileName(currentAttachment.content),
123109
(file) => {
124110
if (isDraft) {
125111
openReport(
@@ -140,7 +126,7 @@ function ShareDetailsPage({
140126
Navigation.navigate(routeToNavigate, {forceReplace: true});
141127
},
142128
() => {},
143-
validatedFile?.type ?? 'image/jpeg',
129+
currentAttachment.mimeType,
144130
);
145131
};
146132

@@ -211,13 +197,13 @@ function ShareDetailsPage({
211197
<SafeAreaView>
212198
<AttachmentModal
213199
headerTitle={fileName}
214-
source={validFilesToUpload.at(0)?.uri}
200+
source={currentAttachment?.content}
215201
originalFileName={fileName}
216202
fallbackSource={FallbackAvatar}
217203
>
218204
{({show}) => (
219205
<AttachmentPreview
220-
source={validFilesToUpload.at(0)?.uri ?? ''}
206+
source={currentAttachment?.content ?? ''}
221207
aspectRatio={currentAttachment?.aspectRatio}
222208
onPress={show}
223209
onLoadError={() => {

src/pages/Share/SubmitDetailsPage.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import type {StackScreenProps} from '@react-navigation/stack';
22
import React, {useEffect, useState} from 'react';
33
import {View} from 'react-native';
44
import type {OnyxEntry} from 'react-native-onyx';
5-
import type {FileObject} from '@components/AttachmentModal';
65
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
76
import HeaderWithBackButton from '@components/HeaderWithBackButton';
87
import LocationPermissionModal from '@components/LocationPermissionModal';
98
import MoneyRequestConfirmationList from '@components/MoneyRequestConfirmationList';
109
import ScreenWrapper from '@components/ScreenWrapper';
1110
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
12-
import useFilesValidation from '@hooks/useFilesValidation';
1311
import useLocalize from '@hooks/useLocalize';
1412
import useOnyx from '@hooks/useOnyx';
1513
import usePermissions from '@hooks/usePermissions';
@@ -62,17 +60,6 @@ function SubmitDetailsPage({
6260
const {isBetaEnabled} = usePermissions();
6361
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS);
6462

65-
const [validFilesToUpload, setValidFilesToUpload] = useState<FileObject[]>([]);
66-
const {validateFiles} = useFilesValidation(setValidFilesToUpload);
67-
68-
useEffect(() => {
69-
if (!currentAttachment || validFilesToUpload.length !== 0) {
70-
return;
71-
}
72-
73-
validateFiles([{name: currentAttachment.id, uri: currentAttachment.content, type: currentAttachment.mimeType}]);
74-
}, [currentAttachment, validFilesToUpload.length, validateFiles]);
75-
7663
useEffect(() => {
7764
if (!errorTitle || !errorMessage) {
7865
return;
@@ -204,13 +191,12 @@ function SubmitDetailsPage({
204191
return;
205192
}
206193

207-
const validatedFile = validFilesToUpload.at(0);
208194
readFileAsync(
209-
validatedFile?.uri ?? '',
210-
getFileName(validatedFile?.name ?? 'shared_image.png'),
195+
currentAttachment?.content ?? '',
196+
getFileName(currentAttachment?.content ?? 'shared_image.png'),
211197
(file) => onSuccess(file, shouldStartLocationPermissionFlow),
212198
() => {},
213-
validatedFile?.type ?? 'image/jpeg',
199+
currentAttachment?.mimeType ?? 'image/jpeg',
214200
);
215201
};
216202

@@ -241,8 +227,8 @@ function SubmitDetailsPage({
241227
iouComment={trimmedComment}
242228
iouCategory={transaction?.category}
243229
onConfirm={() => onConfirm(true)}
244-
receiptPath={validFilesToUpload.at(0)?.uri}
245-
receiptFilename={getFileName(validFilesToUpload.at(0)?.name ?? '')}
230+
receiptPath={currentAttachment?.content}
231+
receiptFilename={getFileName(currentAttachment?.content ?? '')}
246232
reportID={reportOrAccountID}
247233
shouldShowSmartScanFields={false}
248234
isDistanceRequest={false}

0 commit comments

Comments
 (0)