From 94f6f08784e8a8c4e76820bb98b4d5246b89cd24 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Wed, 16 Mar 2022 19:55:03 -0700 Subject: [PATCH] Disable submissions without eating the comment after 1h --- web/components/feed/feed-items.tsx | 14 +++++--------- web/lib/firebase/comments.ts | 4 ---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/web/components/feed/feed-items.tsx b/web/components/feed/feed-items.tsx index 1f5f166a..7d84fe49 100644 --- a/web/components/feed/feed-items.tsx +++ b/web/components/feed/feed-items.tsx @@ -25,11 +25,7 @@ import { import { useUser } from '../../hooks/use-user' import { Linkify } from '../linkify' import { Row } from '../layout/row' -import { - canAddComment, - createComment, - MAX_COMMENT_LENGTH, -} from '../../lib/firebase/comments' +import { createComment, MAX_COMMENT_LENGTH } from '../../lib/firebase/comments' import { formatMoney } from '../../../common/util/format' import { Comment } from '../../../common/comment' import { ResolutionOrChance } from '../contract-card' @@ -180,11 +176,11 @@ function FeedBet(props: { const isSelf = user?.id === userId // You can comment if your bet was posted in the last hour - const canComment = canAddComment(createdTime, isSelf) + const canComment = isSelf && Date.now() - createdTime < 60 * 60 * 1000 const [comment, setComment] = useState('') async function submitComment() { - if (!user || !comment) return + if (!user || !comment || !canComment) return await createComment(contract.id, id, comment, user) } @@ -219,8 +215,7 @@ function FeedBet(props: { )} - {canComment && ( - // Allow user to comment in an textarea if they are the creator + {(canComment || comment) && (