Only use bets by current user for comment input

This commit is contained in:
Ian Philips 2022-04-29 15:06:59 -06:00
parent c13c02f8c0
commit 2352847ab4
2 changed files with 11 additions and 9 deletions

View File

@ -31,7 +31,7 @@ type BaseActivityItem = {
export type CommentInputItem = BaseActivityItem & {
type: 'commentInput'
bets: Bet[]
betsByCurrentUser: Bet[]
comments: Comment[]
}
@ -323,7 +323,7 @@ function getCommentsWithPositions(
id: comment.id,
contract: contract,
comment,
betsBySameUser: bets.length === 0 ? [] : betsByUserId[comment.userId],
betsBySameUser: bets.length === 0 ? [] : betsByUserId[comment.userId] ?? [],
truncate: true,
hideOutcome: false,
smallAvatar: false,
@ -385,7 +385,7 @@ export function getAllContractActivityItems(
type: 'commentInput',
id: 'commentInput',
contract,
bets: [],
betsByCurrentUser: [],
comments: [],
})
} else {
@ -411,7 +411,7 @@ export function getAllContractActivityItems(
type: 'commentInput',
id: 'commentInput',
contract,
bets: [],
betsByCurrentUser: [],
comments: [],
})
}
@ -507,7 +507,9 @@ export function getSpecificContractActivityItems(
type: 'commentInput',
id: 'commentInput',
contract,
bets: bets,
betsByCurrentUser: user
? bets.filter((bet) => bet.userId === user.id)
: [],
comments: comments,
})
break

View File

@ -221,10 +221,10 @@ export function FeedComment(props: {
export function CommentInput(props: {
contract: Contract
bets: Bet[]
betsByCurrentUser: Bet[]
comments: Comment[]
}) {
const { contract, bets, comments } = props
const { contract, betsByCurrentUser, comments } = props
const user = useUser()
const [comment, setComment] = useState('')
@ -238,7 +238,7 @@ export function CommentInput(props: {
}
// Should this be oldest bet or most recent bet?
const mostRecentCommentableBet = bets
const mostRecentCommentableBet = betsByCurrentUser
.filter(
(bet) =>
canCommentOnBet(bet.userId, bet.createdTime, user) &&
@ -258,7 +258,7 @@ export function CommentInput(props: {
)
}
const { userPosition, userPositionMoney, yesFloorShares, noFloorShares } =
getBettorsPosition(contract, Date.now(), bets)
getBettorsPosition(contract, Date.now(), betsByCurrentUser)
return (
<>