From eaa1a26af46ceab94883620c78b887975b217c3d Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 10 Mar 2022 00:29:36 -0600 Subject: [PATCH] Show bets where you can add a comment on contract page feed. --- web/components/contract-feed.tsx | 84 +++++++++++++++++--------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx index 6a507be4..123b175e 100644 --- a/web/components/contract-feed.tsx +++ b/web/components/contract-feed.tsx @@ -44,6 +44,10 @@ import { Avatar } from './avatar' import { useAdmin } from '../hooks/use-admin' import { Answer } from '../../common/answer' +const canAddComment = (createdTime: number, isSelf: boolean) => { + return isSelf && Date.now() - createdTime < 60 * 60 * 1000 +} + function FeedComment(props: { activityItem: any moreHref: string @@ -100,7 +104,7 @@ function FeedBet(props: { activityItem: any; feedType: FeedType }) { const isSelf = user?.id == activityItem.userId const isCreator = contract.creatorId == activityItem.userId // You can comment if your bet was posted in the last hour - const canComment = isSelf && Date.now() - createdTime < 60 * 60 * 1000 + const canComment = canAddComment(createdTime, isSelf) const [comment, setComment] = useState('') async function submitComment() { @@ -132,42 +136,44 @@ function FeedBet(props: { activityItem: any; feedType: FeedType }) { )} -
-
-
- - {isSelf ? 'You' : isCreator ? contract.creatorName : 'A trader'} - {' '} - {bought} {money} - - - {canComment && ( - // Allow user to comment in an textarea if they are the creator -
-