1- import React , { useEffect , useMemo , useRef , useState } from 'react' ;
1+ import React , { useEffect , useRef , useState } from 'react' ;
22import { FlatList , I18nManager , StyleSheet , Text , TouchableOpacity , View } from 'react-native' ;
33
44import { UploadProgressIndicator } from './UploadProgressIndicator' ;
@@ -165,20 +165,21 @@ const FileUploadPreviewWithContext = <
165165
166166 // Handler triggered when an audio is loaded in the message input. The initial state is defined for the audio here and the duration is set.
167167 const onLoad = ( index : string , duration : number ) => {
168+ console . log ( index , duration ) ;
168169 setFilesToDisplay ( ( prevFilesUploads ) =>
169- prevFilesUploads . map ( ( fileUpload , id ) => ( {
170+ prevFilesUploads . map ( ( fileUpload ) => ( {
170171 ...fileUpload ,
171- duration : id . toString ( ) === index ? duration : fileUpload . duration ,
172+ duration : fileUpload . id === index ? duration : fileUpload . duration ,
172173 } ) ) ,
173174 ) ;
174175 } ;
175176
176177 // The handler which is triggered when the audio progresses/ the thumb is dragged in the progress control. The progressed duration is set here.
177178 const onProgress = ( index : string , progress : number ) => {
178179 setFilesToDisplay ( ( prevFilesUploads ) =>
179- prevFilesUploads . map ( ( fileUpload , id ) => ( {
180+ prevFilesUploads . map ( ( fileUpload ) => ( {
180181 ...fileUpload ,
181- progress : id . toString ( ) === index ? progress : fileUpload . progress ,
182+ progress : fileUpload . id === index ? progress : fileUpload . progress ,
182183 } ) ) ,
183184 ) ;
184185 } ;
@@ -188,9 +189,9 @@ const FileUploadPreviewWithContext = <
188189 if ( pausedStatus === false ) {
189190 // If the status is false we set the audio with the index as playing and the others as paused.
190191 setFilesToDisplay ( ( prevFileUploads ) =>
191- prevFileUploads . map ( ( fileUpload , id ) => ( {
192+ prevFileUploads . map ( ( fileUpload ) => ( {
192193 ...fileUpload ,
193- paused : id . toString ( ) !== index ,
194+ paused : fileUpload . id !== index ,
194195 } ) ) ,
195196 ) ;
196197 } else {
@@ -300,18 +301,9 @@ const FileUploadPreviewWithContext = <
300301 }
301302 } , [ fileUploadsLength ] ) ;
302303
303- const memoizedFilesToDisplay = useMemo (
304- ( ) =>
305- filesToDisplay . map ( ( file , index ) => ( {
306- ...file ,
307- id : index . toString ( ) ,
308- } ) ) ,
309- [ filesToDisplay ] ,
310- ) ;
311-
312304 return fileUploadsLength ? (
313305 < FlatList
314- data = { memoizedFilesToDisplay }
306+ data = { filesToDisplay }
315307 getItemLayout = { ( _ , index ) => ( {
316308 index,
317309 length : FILE_PREVIEW_HEIGHT + 8 ,
0 commit comments