Hide ante bets in graph and feed

This commit is contained in:
jahooma 2022-01-13 11:01:20 -06:00
parent 411a739004
commit dfcac2fb97
3 changed files with 19 additions and 1 deletions

View File

@ -11,7 +11,7 @@ import {
XIcon, XIcon,
} from '@heroicons/react/solid' } from '@heroicons/react/solid'
import { useBets } from '../hooks/use-bets' 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 { Comment, mapCommentsByBetId } from '../lib/firebase/comments'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime' import relativeTime from 'dayjs/plugin/relativeTime'
@ -479,6 +479,7 @@ export function ContractFeed(props: {
let bets = useBets(id) let bets = useBets(id)
if (bets === 'loading') bets = [] if (bets === 'loading') bets = []
bets = withoutAnteBets(contract, bets)
let comments = useComments(id) let comments = useComments(id)
if (comments === 'loading') comments = [] if (comments === 'loading') comments = []

View File

@ -4,6 +4,7 @@ import dayjs from 'dayjs'
import { getProbability } from '../../common/calculate' import { getProbability } from '../../common/calculate'
import { useBets } from '../hooks/use-bets' import { useBets } from '../hooks/use-bets'
import { useWindowSize } from '../hooks/use-window-size' import { useWindowSize } from '../hooks/use-window-size'
import { withoutAnteBets } from '../lib/firebase/bets'
import { Contract } from '../lib/firebase/contracts' import { Contract } from '../lib/firebase/contracts'
export function ContractProbGraph(props: { contract: Contract }) { export function ContractProbGraph(props: { contract: Contract }) {
@ -12,6 +13,7 @@ export function ContractProbGraph(props: { contract: Contract }) {
let bets = useBets(id) let bets = useBets(id)
if (bets === 'loading') bets = [] if (bets === 'loading') bets = []
bets = withoutAnteBets(contract, bets)
const startProb = getProbability(phantomShares) const startProb = getProbability(phantomShares)

View File

@ -9,6 +9,7 @@ import _ from 'lodash'
import { db } from './init' import { db } from './init'
import { Bet } from '../../../common/bet' import { Bet } from '../../../common/bet'
import { Contract } from '../../../common/contract'
export type { Bet } export type { Bet }
function getBetsCollection(contractId: string) { function getBetsCollection(contractId: string) {
@ -43,3 +44,17 @@ export function listenForUserBets(
setBets(bets) 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
}