Enforce a max comment length
This commit is contained in:
parent
405604adef
commit
cd8b336635
|
@ -25,7 +25,7 @@ import {
|
||||||
import { useUser } from '../hooks/use-user'
|
import { useUser } from '../hooks/use-user'
|
||||||
import { Linkify } from './linkify'
|
import { Linkify } from './linkify'
|
||||||
import { Row } from './layout/row'
|
import { Row } from './layout/row'
|
||||||
import { createComment } from '../lib/firebase/comments'
|
import { createComment, MAX_COMMENT_LENGTH } from '../lib/firebase/comments'
|
||||||
import { useComments } from '../hooks/use-comments'
|
import { useComments } from '../hooks/use-comments'
|
||||||
import { formatMoney } from '../../common/util/format'
|
import { formatMoney } from '../../common/util/format'
|
||||||
import { ResolutionOrChance } from './contract-card'
|
import { ResolutionOrChance } from './contract-card'
|
||||||
|
@ -135,6 +135,7 @@ function FeedBet(props: { activityItem: any; feedType: FeedType }) {
|
||||||
className="textarea textarea-bordered w-full"
|
className="textarea textarea-bordered w-full"
|
||||||
placeholder="Add a comment..."
|
placeholder="Add a comment..."
|
||||||
rows={3}
|
rows={3}
|
||||||
|
maxLength={MAX_COMMENT_LENGTH}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
||||||
submitComment()
|
submitComment()
|
||||||
|
|
|
@ -14,6 +14,8 @@ import { User } from '../../../common/user'
|
||||||
import { Comment } from '../../../common/comment'
|
import { Comment } from '../../../common/comment'
|
||||||
export type { Comment }
|
export type { Comment }
|
||||||
|
|
||||||
|
export const MAX_COMMENT_LENGTH = 10000
|
||||||
|
|
||||||
export async function createComment(
|
export async function createComment(
|
||||||
contractId: string,
|
contractId: string,
|
||||||
betId: string,
|
betId: string,
|
||||||
|
@ -27,7 +29,7 @@ export async function createComment(
|
||||||
contractId,
|
contractId,
|
||||||
betId,
|
betId,
|
||||||
userId: commenter.id,
|
userId: commenter.id,
|
||||||
text,
|
text: text.slice(0, MAX_COMMENT_LENGTH),
|
||||||
createdTime: Date.now(),
|
createdTime: Date.now(),
|
||||||
userName: commenter.name,
|
userName: commenter.name,
|
||||||
userUsername: commenter.username,
|
userUsername: commenter.username,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user