11import React , { forwardRef , memo , useCallback , useEffect , useImperativeHandle } from 'react' ;
2- import { TextInput , Platform , StyleSheet , type TextInputProps , InteractionManager , Alert } from 'react-native' ;
2+ import { StyleSheet , type TextInputProps , InteractionManager , Alert } from 'react-native' ;
33import { useDebouncedCallback } from 'use-debounce' ;
44import { useDispatch } from 'react-redux' ;
55import { type RouteProp , useFocusEffect , useRoute } from '@react-navigation/native' ;
@@ -78,8 +78,6 @@ export const ComposerInput = memo(
7878 const allowList = FileUpload_MediaTypeWhiteList as string ;
7979 const maxFileSize = FileUpload_MaxFileSize as number ;
8080
81- const isAndroid = Platform . OS === 'android' ;
82-
8381 // subscribe to changes on mic state to update draft after a message is sent
8482 useMicOrSend ( ) ;
8583 const { saveMessageDraft } = useAutoSaveDraft ( textRef . current ) ;
@@ -189,11 +187,7 @@ export const ComposerInput = memo(
189187 saveMessageDraft ( '' ) ;
190188 }
191189
192- if ( isAndroid ) {
193- inputRef . current ?. setText ( text ) ;
194- } else {
195- inputRef . current ?. setNativeProps ?.( { text } ) ; // keep TextInput path
196- }
190+ inputRef . current ?. setText ( text ) ;
197191
198192 if ( selection ) {
199193 // setSelection won't trigger onSelectionChange, so we need it to be ran after new text is set
@@ -219,10 +213,6 @@ export const ComposerInput = memo(
219213 setInput ( text ) ;
220214 } ;
221215
222- const onSelectionChange : TextInputProps [ 'onSelectionChange' ] = e => {
223- selectionRef . current = e . nativeEvent . selection ;
224- } ;
225-
226216 const onChangeSelection = ( e : OnChangeSelectionEvent ) => {
227217 const { start, end } = e ;
228218 const selection = { start, end } ;
@@ -239,18 +229,11 @@ export const ComposerInput = memo(
239229 stopAutocomplete ( ) ;
240230 }
241231 } ;
242- const onFocus : TextInputProps [ 'onFocus' ] = ( ) => {
243- handleFocus ( ) ;
244- } ;
245232
246233 const onTouchStart : TextInputProps [ 'onTouchStart' ] = ( ) => {
247234 setFocused ( true ) ;
248235 } ;
249236
250- const onBlur : TextInputProps [ 'onBlur' ] = ( ) => {
251- handleBlur ( ) ;
252- } ;
253-
254237 const onAutocompleteItemSelected : IAutocompleteItemProps [ 'onPress' ] = async item => {
255238 if ( item . type === 'loading' ) {
256239 return null ;
@@ -403,8 +386,10 @@ export const ComposerInput = memo(
403386 const finishShareView = ( text = '' , quotes = [ ] ) => setQuotesAndText ?.( text , quotes ) ;
404387
405388 const handleOnImagePaste = async ( e : onPasteImageEventData ) => {
406- if ( e . error ) {
389+ console . log ( e ) ;
390+ if ( e . error ?. message ) {
407391 handleError ( e . error . message ) ;
392+ console . log ( 'error detected' ) ;
408393 return ;
409394 }
410395 if ( ! rid ) return ;
@@ -444,6 +429,8 @@ export const ComposerInput = memo(
444429 startShareView
445430 } ) ;
446431 } else {
432+ console . log ( 'can upload error' ) ;
433+
447434 handleError ( canUploadResult . error ) ;
448435 }
449436 } ;
@@ -454,53 +441,30 @@ export const ComposerInput = memo(
454441
455442 return (
456443 < >
457- { isAndroid ? (
458- < TypeRichTextInput
459- style = { [ styles . textInput ] }
460- color = { colors . fontDefault }
461- placeholder = { placeholder }
462- placeholderTextColor = { colors . fontAnnotation }
463- ref = { component => {
464- inputRef . current = component ;
465- } }
466- // blurOnSubmit={false} // not needed
467- onChangeText = { onChangeText }
468- onTouchStart = { onTouchStart }
469- onChangeSelection = { onChangeSelection }
470- onFocus = { handleFocus } // typerich onFocus / onBlur events doesn't pass any arguments to callbacks
471- onBlur = { handleBlur }
472- // underlineColorAndroid='transparent' // by default behaiviour
473- defaultValue = ''
474- multiline
475- { ...( autocompleteType ? { autoComplete : 'off' , autoCorrect : false , autoCapitalize : 'none' } : { } ) }
476- keyboardAppearance = { theme === 'light' ? 'light' : 'dark' }
477- // eslint-disable-next-line no-nested-ternary
478- testID = { `message-composer-input${ tmid ? '-thread' : sharing ? '-share' : '' } ` }
479- onPasteImageData = { handleOnImagePaste }
480- />
481- ) : (
482- < TextInput
483- style = { [ styles . textInput , { color : colors . fontDefault } ] }
484- placeholder = { placeholder }
485- placeholderTextColor = { colors . fontAnnotation }
486- ref = { component => {
487- inputRef . current = component ;
488- } }
489- blurOnSubmit = { false }
490- onChangeText = { onChangeText }
491- onTouchStart = { onTouchStart }
492- onSelectionChange = { onSelectionChange }
493- onFocus = { onFocus }
494- onBlur = { onBlur }
495- underlineColorAndroid = 'transparent'
496- defaultValue = ''
497- multiline
498- { ...( autocompleteType ? { autoComplete : 'off' , autoCorrect : false , autoCapitalize : 'none' } : { } ) }
499- keyboardAppearance = { theme === 'light' ? 'light' : 'dark' }
500- // eslint-disable-next-line no-nested-ternary
501- testID = { `message-composer-input${ tmid ? '-thread' : sharing ? '-share' : '' } ` }
502- />
503- ) }
444+ < TypeRichTextInput
445+ style = { [ styles . textInput ] }
446+ color = { colors . fontDefault }
447+ placeholder = { placeholder }
448+ placeholderTextColor = { colors . fontAnnotation }
449+ ref = { component => {
450+ inputRef . current = component ;
451+ } }
452+ // blurOnSubmit={false} // not needed
453+ onChangeText = { onChangeText }
454+ onTouchStart = { onTouchStart }
455+ onChangeSelection = { onChangeSelection }
456+ onFocus = { handleFocus } // typerich onFocus / onBlur events doesn't pass any arguments to callbacks
457+ onBlur = { handleBlur }
458+ // underlineColorAndroid='transparent' // by default behaiviour
459+ defaultValue = ''
460+ multiline
461+ editable
462+ { ...( autocompleteType ? { autoComplete : 'off' , autoCorrect : false , autoCapitalize : 'none' } : { } ) }
463+ keyboardAppearance = { theme === 'light' ? 'light' : 'dark' }
464+ // eslint-disable-next-line no-nested-ternary
465+ testID = { `message-composer-input${ tmid ? '-thread' : sharing ? '-share' : '' } ` }
466+ onPasteImageData = { handleOnImagePaste }
467+ />
504468 </ >
505469 ) ;
506470 } )
0 commit comments