Only calculate current users bets once

This commit is contained in:
Ian Philips 2022-05-17 15:43:56 -06:00
parent 45dffda46c
commit 419a356b88

View File

@ -279,6 +279,7 @@ function getAnswerAndCommentInputGroups(
outcomes = _.sortBy(outcomes, (outcome) =>
getOutcomeProbability(contract, outcome)
)
const betsByCurrentUser = bets.filter((bet) => bet.userId === user?.id)
const answerGroups = outcomes
.map((outcome) => {
@ -301,7 +302,7 @@ function getAnswerAndCommentInputGroups(
answer,
items,
user,
betsByCurrentUser: bets.filter((bet) => bet.userId === user?.id),
betsByCurrentUser: betsByCurrentUser,
commentsByCurrentUser: answerComments.filter(
(comment) => comment.userId === user?.id
),