Show free comments in feed
This commit is contained in:
parent
a525ad82ec
commit
8109f3d9a9
|
@ -256,6 +256,47 @@ function getAnswerGroups(
|
||||||
return answerGroups
|
return answerGroups
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function groupBetsAndComments(
|
||||||
|
bets: Bet[],
|
||||||
|
comments: Comment[],
|
||||||
|
contract: Contract,
|
||||||
|
userId: string | undefined,
|
||||||
|
options: {
|
||||||
|
hideOutcome: boolean
|
||||||
|
abbreviated: boolean
|
||||||
|
smallAvatar: boolean
|
||||||
|
reversed: boolean
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
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, userId, options)
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return sortedBetsAndComments
|
||||||
|
}
|
||||||
|
|
||||||
export function getAllContractActivityItems(
|
export function getAllContractActivityItems(
|
||||||
contract: Contract,
|
contract: Contract,
|
||||||
bets: Bet[],
|
bets: Bet[],
|
||||||
|
@ -301,38 +342,14 @@ export function getAllContractActivityItems(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
const commentsWithoutBets = comments
|
items.push(
|
||||||
.filter((comment) => !comment.betId)
|
...groupBetsAndComments(bets, comments, contract, user?.id, {
|
||||||
.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,
|
hideOutcome: false,
|
||||||
abbreviated,
|
abbreviated,
|
||||||
smallAvatar: false,
|
smallAvatar: false,
|
||||||
reversed: false,
|
reversed,
|
||||||
})
|
})
|
||||||
|
)
|
||||||
// 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()) {
|
||||||
|
@ -392,7 +409,7 @@ export function getRecentContractActivityItems(
|
||||||
reversed: false,
|
reversed: false,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
: groupBets(bets, comments, contract, user?.id, {
|
: groupBetsAndComments(bets, comments, contract, user?.id, {
|
||||||
hideOutcome: false,
|
hideOutcome: false,
|
||||||
abbreviated: true,
|
abbreviated: true,
|
||||||
smallAvatar: false,
|
smallAvatar: false,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user