@@ -11,15 +11,11 @@ import { Alert, Keyboard, Linking, TextInput, TextInputProps } from 'react-nativ
1111
1212import { BottomSheetHandleProps } from '@gorhom/bottom-sheet' ;
1313import {
14- createCommandInjectionMiddleware ,
15- createCommandStringExtractionMiddleware ,
16- createDraftCommandInjectionMiddleware ,
1714 LocalMessage ,
1815 Message ,
1916 SendMessageOptions ,
2017 StreamChat ,
2118 Message as StreamMessage ,
22- TextComposerMiddleware ,
2319 UpdateMessageOptions ,
2420 UploadRequestFn ,
2521 UserResponse ,
@@ -67,6 +63,7 @@ import {
6763import { isDocumentPickerAvailable , MediaTypes , NativeHandlers } from '../../native' ;
6864import { File } from '../../types/types' ;
6965import { compressedImageURI } from '../../utils/compressImage' ;
66+ import { setupCommandUIMiddleware } from '../../utils/setupCommandUIMiddleware' ;
7067import {
7168 AttachmentPickerIconProps ,
7269 useAttachmentPickerContext ,
@@ -428,7 +425,7 @@ export const MessageInputProvider = ({
428425 useAttachmentPickerContext ( ) ;
429426 const { client, enableOfflineSupport } = useChatContext ( ) ;
430427
431- const { isCommandUIEnabled , uploadAbortControllerRef } = useChannelContext ( ) ;
428+ const { uploadAbortControllerRef } = useChannelContext ( ) ;
432429 const { clearEditingState } = useMessageComposerAPIContext ( ) ;
433430 const { thread } = useThreadContext ( ) ;
434431 const { t } = useTranslationContext ( ) ;
@@ -462,21 +459,8 @@ export const MessageInputProvider = ({
462459 attachmentManager . setCustomUploadFn ( value . doFileUploadRequest ) ;
463460 }
464461
465- if ( isCommandUIEnabled ) {
466- messageComposer . compositionMiddlewareExecutor . insert ( {
467- middleware : [ createCommandInjectionMiddleware ( messageComposer ) ] ,
468- position : { after : 'stream-io/message-composer-middleware/attachments' } ,
469- } ) ;
470-
471- messageComposer . draftCompositionMiddlewareExecutor . insert ( {
472- middleware : [ createDraftCommandInjectionMiddleware ( messageComposer ) ] ,
473- position : { after : 'stream-io/message-composer-middleware/draft-attachments' } ,
474- } ) ;
475-
476- messageComposer . textComposer . middlewareExecutor . insert ( {
477- middleware : [ createCommandStringExtractionMiddleware ( ) as TextComposerMiddleware ] ,
478- position : { after : 'stream-io/text-composer/commands-middleware' } ,
479- } ) ;
462+ if ( value . isCommandUIEnabled ) {
463+ setupCommandUIMiddleware ( messageComposer ) ;
480464 }
481465
482466 if ( enableOfflineSupport ) {
@@ -490,7 +474,7 @@ export const MessageInputProvider = ({
490474 }
491475 } , [
492476 value . doFileUploadRequest ,
493- isCommandUIEnabled ,
477+ value . isCommandUIEnabled ,
494478 enableOfflineSupport ,
495479 messageComposer ,
496480 attachmentManager ,
0 commit comments