From dfcac2fb97755a30ea3e48eaec6095d917295298 Mon Sep 17 00:00:00 2001 From: jahooma Date: Thu, 13 Jan 2022 11:01:20 -0600 Subject: [PATCH] Hide ante bets in graph and feed --- web/components/contract-feed.tsx | 3 ++- web/components/contract-prob-graph.tsx | 2 ++ web/lib/firebase/bets.ts | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx index 9576b80e..572f7bc5 100644 --- a/web/components/contract-feed.tsx +++ b/web/components/contract-feed.tsx @@ -11,7 +11,7 @@ import { XIcon, } from '@heroicons/react/solid' import { useBets } from '../hooks/use-bets' -import { Bet } from '../lib/firebase/bets' +import { Bet, withoutAnteBets } from '../lib/firebase/bets' import { Comment, mapCommentsByBetId } from '../lib/firebase/comments' import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' @@ -479,6 +479,7 @@ export function ContractFeed(props: { let bets = useBets(id) if (bets === 'loading') bets = [] + bets = withoutAnteBets(contract, bets) let comments = useComments(id) if (comments === 'loading') comments = [] diff --git a/web/components/contract-prob-graph.tsx b/web/components/contract-prob-graph.tsx index 691a662e..6276314f 100644 --- a/web/components/contract-prob-graph.tsx +++ b/web/components/contract-prob-graph.tsx @@ -4,6 +4,7 @@ import dayjs from 'dayjs' import { getProbability } from '../../common/calculate' import { useBets } from '../hooks/use-bets' import { useWindowSize } from '../hooks/use-window-size' +import { withoutAnteBets } from '../lib/firebase/bets' import { Contract } from '../lib/firebase/contracts' export function ContractProbGraph(props: { contract: Contract }) { @@ -12,6 +13,7 @@ export function ContractProbGraph(props: { contract: Contract }) { let bets = useBets(id) if (bets === 'loading') bets = [] + bets = withoutAnteBets(contract, bets) const startProb = getProbability(phantomShares) diff --git a/web/lib/firebase/bets.ts b/web/lib/firebase/bets.ts index 8f6d49eb..0c7b1394 100644 --- a/web/lib/firebase/bets.ts +++ b/web/lib/firebase/bets.ts @@ -9,6 +9,7 @@ import _ from 'lodash' import { db } from './init' import { Bet } from '../../../common/bet' +import { Contract } from '../../../common/contract' export type { Bet } function getBetsCollection(contractId: string) { @@ -43,3 +44,17 @@ export function listenForUserBets( setBets(bets) }) } + +export function withoutAnteBets(contract: Contract, bets: Bet[]) { + const { createdTime } = contract + + if ( + bets.length >= 2 && + bets[0].createdTime === createdTime && + bets[1].createdTime === createdTime + ) { + return bets.slice(2) + } + + return bets +}