feat: [closes #18] limit message character size to 10,000

This commit is contained in:
Jeremy Kahn 2022-09-15 20:15:43 -05:00
parent e891339907
commit f2aeec5acb
2 changed files with 11 additions and 1 deletions

View File

@ -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<HTMLInputElement>) => {
@ -49,6 +55,9 @@ export const MessageForm = ({
if (key === 'Enter' && shiftKey === false) {
event.preventDefault()
if (!canMessageBeSent()) return
submitMessage()
}
}

1
src/config/messaging.ts Normal file
View File

@ -0,0 +1 @@
export const messageCharacterSizeLimit = 10_000