File tree Expand file tree Collapse file tree
social-messenger-ts/src/components/SendButton
virtual-event/src/components/Chat Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { SendIcon } from '../../assets' ;
22import React from 'react' ;
3- import type { SendButtonProps } from 'stream-chat-react' ;
3+ import { SendButtonProps , useMessageComposerHasSendableData } from 'stream-chat-react' ;
44
5- const SendButton = ( { sendMessage, ...rest } : SendButtonProps ) => (
6- < button
7- className = 'str-chat__send-button'
8- onClick = { sendMessage }
9- type = 'button'
10- { ...rest }
11- >
12- < SendIcon />
13- </ button >
14- ) ;
5+ const SendButton = ( { sendMessage, ...rest } : SendButtonProps ) => {
6+ const hasSendableData = useMessageComposerHasSendableData ( ) ;
7+ return (
8+ < button
9+ className = 'str-chat__send-button'
10+ disabled = { ! hasSendableData }
11+ onClick = { sendMessage }
12+ type = 'button'
13+ { ...rest }
14+ >
15+ < SendIcon />
16+ </ button >
17+ ) ;
18+ } ;
1519
1620export default SendButton ;
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ export const MessageInputUI = () => {
7575 const commandSearchSource = useMemo ( ( ) => new CommandSearchSource ( textComposer . channel ) ,
7676 [ textComposer ]
7777 ) ;
78+ const hasSendableData = useMessageComposerHasSendableData ( ) ;
7879
7980 return (
8081 < div className = 'input-ui-container' >
@@ -85,7 +86,7 @@ export const MessageInputUI = () => {
8586 < >
8687 < button
8788 className = { `input-ui-input-commands-button ${ cooldownRemaining ? 'cooldown' : '' } ` }
88- disabled = { ! ! cooldownRemaining }
89+ disabled = { ! ! cooldownRemaining || ! hasSendableData }
8990 onClick = { ( ) => {
9091 commandSearchSource . resetStateAndActivate ( ) ;
9192 commandSearchSource . search ( ) ;
You can’t perform that action at this time.
0 commit comments