From b599935d1c08506e387826eb726640fbe9bffe05 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Wed, 27 Apr 2022 09:58:03 -0600 Subject: [PATCH] Show position in bin. markets, no comments on bets --- web/components/feed/feed-items.tsx | 60 ++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/web/components/feed/feed-items.tsx b/web/components/feed/feed-items.tsx index 7518c998..eb2cd174 100644 --- a/web/components/feed/feed-items.tsx +++ b/web/components/feed/feed-items.tsx @@ -39,7 +39,13 @@ import BetRow from '../bet-row' import { Avatar } from '../avatar' import { Answer } from '../../../common/answer' import { ActivityItem } from './activity-items' -import { FreeResponse, FullContract } from '../../../common/contract' +import { + Binary, + CPMM, + DPM, + FreeResponse, + FullContract, +} from '../../../common/contract' import { BuyButton } from '../yes-no-selector' import { getDpmOutcomeProbability } from '../../../common/calculate-dpm' import { AnswerBetPanel } from '../answers/answer-bet-panel' @@ -50,6 +56,8 @@ import { trackClick } from '../../lib/firebase/tracking' import { firebaseLogin } from '../../lib/firebase/users' import { DAY_MS } from '../../../common/util/time' import NewContractBadge from '../new-contract-badge' +import { useUserContractBets } from '../../hooks/use-user-bets' +import { useSaveShares } from '../use-save-shares' export function FeedItems(props: { contract: Contract @@ -137,7 +145,15 @@ export function FeedComment(props: { bought = bet.amount >= 0 ? 'bought' : 'sold' money = formatMoney(Math.abs(bet.amount)) } - const { text, userUsername, userName, userAvatarUrl, createdTime } = comment + const { text, userUsername, userName, userAvatarUrl, createdTime, userId } = + comment + + const userBets = useUserContractBets(userId, contract.id) + const { yesFloorShares, noFloorShares } = useSaveShares( + contract as FullContract, + userBets + ) + const userPosition = yesFloorShares || noFloorShares return ( <> @@ -155,16 +171,34 @@ export function FeedComment(props: { username={userUsername} name={userName} />{' '} - {bought} {money} - {!hideOutcome && ( + {contract.outcomeType === 'BINARY' ? ( + userPosition > 0 && ( + <> + {'owns ' + userPosition + ' shares '} + <> + {' of '} + noFloorShares ? 'YES' : 'NO'} + contract={contract} + truncate="short" + /> + + + ) + ) : ( <> - {' '} - of{' '} - + {bought} {money} + {!hideOutcome && ( + <> + {' '} + of{' '} + + + )} )} @@ -255,7 +289,9 @@ export function FeedBet(props: { const { id, amount, outcome, createdTime, userId } = bet const user = useUser() const isSelf = user?.id === userId - const canComment = canCommentOnBet(userId, createdTime, user) + const canComment = + canCommentOnBet(userId, createdTime, user) && + contract.outcomeType !== 'BINARY' const [comment, setComment] = useState('') async function submitComment() {