Merge remote-tracking branch 'upstream/main' into automated-market-resolution
This commit is contained in:
commit
cf99ba1a83
|
@ -28,6 +28,7 @@ import { AvatarDetails, MiscDetails } from './contract-details'
|
||||||
import { getExpectedValue, getValueFromBucket } from 'common/calculate-dpm'
|
import { getExpectedValue, getValueFromBucket } from 'common/calculate-dpm'
|
||||||
import { QuickBet, ProbBar, getColor } from './quick-bet'
|
import { QuickBet, ProbBar, getColor } from './quick-bet'
|
||||||
import { useContractWithPreload } from 'web/hooks/use-contract'
|
import { useContractWithPreload } from 'web/hooks/use-contract'
|
||||||
|
import { useUser } from 'web/hooks/use-user'
|
||||||
|
|
||||||
export function ContractCard(props: {
|
export function ContractCard(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
@ -40,10 +41,16 @@ export function ContractCard(props: {
|
||||||
const { question, outcomeType } = contract
|
const { question, outcomeType } = contract
|
||||||
const { resolution } = contract
|
const { resolution } = contract
|
||||||
|
|
||||||
const marketClosed = (contract.closeTime || Infinity) < Date.now()
|
const user = useUser()
|
||||||
|
|
||||||
|
const marketClosed =
|
||||||
|
(contract.closeTime || Infinity) < Date.now() || !!resolution
|
||||||
|
|
||||||
const showQuickBet = !(
|
const showQuickBet = !(
|
||||||
|
!user ||
|
||||||
marketClosed ||
|
marketClosed ||
|
||||||
(outcomeType === 'FREE_RESPONSE' && getTopAnswer(contract) === undefined)
|
(outcomeType === 'FREE_RESPONSE' && getTopAnswer(contract) === undefined) ||
|
||||||
|
outcomeType === 'NUMERIC'
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -96,7 +103,7 @@ export function ContractCard(props: {
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
{showQuickBet ? (
|
{showQuickBet ? (
|
||||||
<QuickBet contract={contract} />
|
<QuickBet contract={contract} user={user} />
|
||||||
) : (
|
) : (
|
||||||
<Col className="m-auto pl-2">
|
<Col className="m-auto pl-2">
|
||||||
{outcomeType === 'BINARY' && (
|
{outcomeType === 'BINARY' && (
|
||||||
|
|
|
@ -19,7 +19,7 @@ export function ContractsGrid(props: {
|
||||||
const isBottomVisible = useIsVisible(elem)
|
const isBottomVisible = useIsVisible(elem)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isBottomVisible) {
|
if (isBottomVisible && hasMore) {
|
||||||
loadMore()
|
loadMore()
|
||||||
}
|
}
|
||||||
}, [isBottomVisible, hasMore, loadMore])
|
}, [isBottomVisible, hasMore, loadMore])
|
||||||
|
|
|
@ -15,6 +15,7 @@ import {
|
||||||
FreeResponseContract,
|
FreeResponseContract,
|
||||||
resolution,
|
resolution,
|
||||||
} from 'common/contract'
|
} from 'common/contract'
|
||||||
|
import { User } from 'common/user'
|
||||||
import {
|
import {
|
||||||
formatLargeNumber,
|
formatLargeNumber,
|
||||||
formatMoney,
|
formatMoney,
|
||||||
|
@ -22,7 +23,6 @@ import {
|
||||||
} from 'common/util/format'
|
} from 'common/util/format'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
import { useUser } from 'web/hooks/use-user'
|
|
||||||
import { useUserContractBets } from 'web/hooks/use-user-bets'
|
import { useUserContractBets } from 'web/hooks/use-user-bets'
|
||||||
import { placeBet } from 'web/lib/firebase/api-call'
|
import { placeBet } from 'web/lib/firebase/api-call'
|
||||||
import { getBinaryProb, getBinaryProbPercent } from 'web/lib/firebase/contracts'
|
import { getBinaryProb, getBinaryProbPercent } from 'web/lib/firebase/contracts'
|
||||||
|
@ -34,11 +34,10 @@ import { useSaveShares } from '../use-save-shares'
|
||||||
|
|
||||||
const BET_SIZE = 10
|
const BET_SIZE = 10
|
||||||
|
|
||||||
export function QuickBet(props: { contract: Contract }) {
|
export function QuickBet(props: { contract: Contract; user: User }) {
|
||||||
const { contract } = props
|
const { contract, user } = props
|
||||||
|
|
||||||
const user = useUser()
|
const userBets = useUserContractBets(user.id, contract.id)
|
||||||
const userBets = useUserContractBets(user?.id, contract.id)
|
|
||||||
const topAnswer =
|
const topAnswer =
|
||||||
contract.outcomeType === 'FREE_RESPONSE'
|
contract.outcomeType === 'FREE_RESPONSE'
|
||||||
? getTopAnswer(contract as FreeResponseContract)
|
? getTopAnswer(contract as FreeResponseContract)
|
||||||
|
|
|
@ -479,9 +479,7 @@ export function getRecentContractActivityItems(
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const { contractPath } = options
|
const { contractPath } = options
|
||||||
bets = bets
|
bets = bets.sort((b1, b2) => b1.createdTime - b2.createdTime)
|
||||||
.filter((bet) => !bet.isRedemption)
|
|
||||||
.sort((b1, b2) => b1.createdTime - b2.createdTime)
|
|
||||||
comments = comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
comments = comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
||||||
|
|
||||||
const questionItem: QuestionItem = {
|
const questionItem: QuestionItem = {
|
||||||
|
|
|
@ -39,7 +39,7 @@ export function ContractActivity(props: {
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const updatedBets = mode === 'only-recent' ? undefined : useBets(contract.id)
|
const updatedBets = mode === 'only-recent' ? undefined : useBets(contract.id)
|
||||||
const bets = updatedBets ?? props.bets
|
const bets = (updatedBets ?? props.bets).filter((bet) => !bet.isRedemption)
|
||||||
|
|
||||||
const items =
|
const items =
|
||||||
mode === 'only-recent'
|
mode === 'only-recent'
|
||||||
|
|
|
@ -202,7 +202,7 @@ export default function Sidebar(props: { className?: string }) {
|
||||||
{user ? (
|
{user ? (
|
||||||
<Link href={'/create'} passHref>
|
<Link href={'/create'} passHref>
|
||||||
<button className={clsx(gradient, buttonStyle)}>
|
<button className={clsx(gradient, buttonStyle)}>
|
||||||
Ask a question
|
Create a question
|
||||||
</button>
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user