From ed139b6b2b622ffa235528b8f6319aeeda37f0c6 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Thu, 21 Apr 2022 09:31:01 -0600 Subject: [PATCH] No free comments on free response questions --- web/components/feed/activity-items.ts | 67 +++++++++++++-------------- web/components/feed/feed-items.tsx | 3 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/web/components/feed/activity-items.ts b/web/components/feed/activity-items.ts index 6e64d24a..1e8cd71b 100644 --- a/web/components/feed/activity-items.ts +++ b/web/components/feed/activity-items.ts @@ -286,40 +286,6 @@ export function getAllContractActivityItems( ] : [{ type: 'description', id: '0', contract }] - const commentsWithoutBets = comments - .filter((comment) => !comment.betId) - .map((comment) => ({ - type: 'comment' as const, - id: comment.id, - contract: contract, - comment, - bet: undefined, - truncate: false, - hideOutcome: true, - smallAvatar: false, - })) - - const groupedBets = groupBets(bets, comments, contract, user?.id, { - hideOutcome: false, - abbreviated, - smallAvatar: false, - reversed: false, - }) - - // iterate through the bets and comment activity items and add them to the items in order of comment creation time: - const unorderedBetsAndComments = [...commentsWithoutBets, ...groupedBets] - const sortedBetsAndComments = _.sortBy(unorderedBetsAndComments, (item) => { - if (item.type === 'comment') { - return item.comment.createdTime - } else if (item.type === 'bet') { - return item.bet.createdTime - } else if (item.type === 'betgroup') { - return item.bets[0].createdTime - } - }) - - items.push(...sortedBetsAndComments) - if (outcomeType === 'FREE_RESPONSE') { items.push( ...getAnswerGroups( @@ -334,6 +300,39 @@ export function getAllContractActivityItems( } ) ) + } else { + const commentsWithoutBets = comments + .filter((comment) => !comment.betId) + .map((comment) => ({ + type: 'comment' as const, + id: comment.id, + contract: contract, + comment, + bet: undefined, + truncate: false, + hideOutcome: true, + smallAvatar: false, + })) + + const groupedBets = groupBets(bets, comments, contract, user?.id, { + hideOutcome: false, + abbreviated, + smallAvatar: false, + reversed: false, + }) + + // iterate through the bets and comment activity items and add them to the items in order of comment creation time: + const unorderedBetsAndComments = [...commentsWithoutBets, ...groupedBets] + const sortedBetsAndComments = _.sortBy(unorderedBetsAndComments, (item) => { + if (item.type === 'comment') { + return item.comment.createdTime + } else if (item.type === 'bet') { + return item.bet.createdTime + } else if (item.type === 'betgroup') { + return item.bets[0].createdTime + } + }) + items.push(...sortedBetsAndComments) } if (contract.closeTime && contract.closeTime <= Date.now()) { diff --git a/web/components/feed/feed-items.tsx b/web/components/feed/feed-items.tsx index 7e1ab4a7..e9169aaa 100644 --- a/web/components/feed/feed-items.tsx +++ b/web/components/feed/feed-items.tsx @@ -187,10 +187,11 @@ export function CommentInput(props: { }) { // see if we can comment input on any bet: const { contract, bets, commentsByBetId } = props + const { outcomeType } = contract const user = useUser() const [comment, setComment] = useState('') - if (!user) { + if (!user || outcomeType === 'FREE_RESPONSE') { return
}