No free comments on free response questions

This commit is contained in:
Ian Philips 2022-04-21 09:31:01 -06:00
parent 6de12efa99
commit ed139b6b2b
2 changed files with 35 additions and 35 deletions

View File

@ -286,40 +286,6 @@ export function getAllContractActivityItems(
] ]
: [{ type: 'description', id: '0', contract }] : [{ 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') { if (outcomeType === 'FREE_RESPONSE') {
items.push( items.push(
...getAnswerGroups( ...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()) { if (contract.closeTime && contract.closeTime <= Date.now()) {

View File

@ -187,10 +187,11 @@ export function CommentInput(props: {
}) { }) {
// see if we can comment input on any bet: // see if we can comment input on any bet:
const { contract, bets, commentsByBetId } = props const { contract, bets, commentsByBetId } = props
const { outcomeType } = contract
const user = useUser() const user = useUser()
const [comment, setComment] = useState('') const [comment, setComment] = useState('')
if (!user) { if (!user || outcomeType === 'FREE_RESPONSE') {
return <div /> return <div />
} }