diff --git a/src/components/MessageForm/MessageForm.tsx b/src/components/MessageForm/MessageForm.tsx index 506d8b4..6784487 100644 --- a/src/components/MessageForm/MessageForm.tsx +++ b/src/components/MessageForm/MessageForm.tsx @@ -11,6 +11,8 @@ import TextField from '@mui/material/TextField' import Fab from '@mui/material/Fab' import ArrowUpward from '@mui/icons-material/ArrowUpward' +import { messageCharacterSizeLimit } from 'config/messaging' + interface MessageFormProps { onMessageSubmit: (message: string) => void isMessageSending: boolean @@ -31,7 +33,11 @@ export const MessageForm = ({ }, [textFieldRef]) const canMessageBeSent = () => { - return textMessage.trim().length > 0 && textMessage.trim().length < 1000 && !isMessageSending + return ( + textMessage.trim().length > 0 && + textMessage.length < messageCharacterSizeLimit && + !isMessageSending + ) } const handleMessageChange = (event: React.ChangeEvent) => { @@ -49,6 +55,9 @@ export const MessageForm = ({ if (key === 'Enter' && shiftKey === false) { event.preventDefault() + + if (!canMessageBeSent()) return + submitMessage() } } diff --git a/src/config/messaging.ts b/src/config/messaging.ts new file mode 100644 index 0000000..3a7b72a --- /dev/null +++ b/src/config/messaging.ts @@ -0,0 +1 @@ +export const messageCharacterSizeLimit = 10_000