forked from Shiloh/remnantchat
feat: [closes #18] limit message character size to 10,000
This commit is contained in:
parent
e891339907
commit
f2aeec5acb
@ -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
1
src/config/messaging.ts
Normal file
@ -0,0 +1 @@
|
||||
export const messageCharacterSizeLimit = 10_000
|
Loading…
Reference in New Issue
Block a user