@@ -2,7 +2,6 @@ import type {StackScreenProps} from '@react-navigation/stack';
22import React , { useEffect , useMemo , useState } from 'react' ;
33import { SafeAreaView , View } from 'react-native' ;
44import type { OnyxEntry } from 'react-native-onyx' ;
5- import type { FileObject } from '@components/AttachmentModal' ;
65import AttachmentModal from '@components/AttachmentModal' ;
76import AttachmentPreview from '@components/AttachmentPreview' ;
87import Button from '@components/Button' ;
@@ -14,7 +13,6 @@ import ScreenWrapper from '@components/ScreenWrapper';
1413import ScrollView from '@components/ScrollView' ;
1514import Text from '@components/Text' ;
1615import TextInput from '@components/TextInput' ;
17- import useFilesValidation from '@hooks/useFilesValidation' ;
1816import useLocalize from '@hooks/useLocalize' ;
1917import useOnyx from '@hooks/useOnyx' ;
2018import 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 = { ( ) => {
0 commit comments