From 29a05ffff221ea2c854104aa4ccdf199f29a015b Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sat, 28 May 2022 15:26:55 -0500 Subject: [PATCH 1/4] Disable quick bet for resolved markets --- web/components/contract/contract-card.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/components/contract/contract-card.tsx b/web/components/contract/contract-card.tsx index 84e2db8f..127a8b7f 100644 --- a/web/components/contract/contract-card.tsx +++ b/web/components/contract/contract-card.tsx @@ -40,7 +40,7 @@ export function ContractCard(props: { const { question, outcomeType } = contract const { resolution } = contract - const marketClosed = (contract.closeTime || Infinity) < Date.now() + const marketClosed = (contract.closeTime || Infinity) < Date.now() || !!resolution const showQuickBet = !( marketClosed || (outcomeType === 'FREE_RESPONSE' && getTopAnswer(contract) === undefined) From 4c81106612f9305e9c033c5a231d7578c6292bae Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sat, 28 May 2022 15:36:16 -0500 Subject: [PATCH 2/4] Don't show quick bet when signed out, or for numeric markets --- web/components/contract/contract-card.tsx | 13 ++++++++++--- web/components/contract/contracts-list.tsx | 2 +- web/components/contract/quick-bet.tsx | 9 ++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/web/components/contract/contract-card.tsx b/web/components/contract/contract-card.tsx index 127a8b7f..a98aa18a 100644 --- a/web/components/contract/contract-card.tsx +++ b/web/components/contract/contract-card.tsx @@ -28,6 +28,7 @@ import { AvatarDetails, MiscDetails } from './contract-details' import { getExpectedValue, getValueFromBucket } from 'common/calculate-dpm' import { QuickBet, ProbBar, getColor } from './quick-bet' import { useContractWithPreload } from 'web/hooks/use-contract' +import { useUser } from 'web/hooks/use-user' export function ContractCard(props: { contract: Contract @@ -40,10 +41,16 @@ export function ContractCard(props: { const { question, outcomeType } = contract const { resolution } = contract - const marketClosed = (contract.closeTime || Infinity) < Date.now() || !!resolution + const user = useUser() + + const marketClosed = + (contract.closeTime || Infinity) < Date.now() || !!resolution + const showQuickBet = !( + !user || marketClosed || - (outcomeType === 'FREE_RESPONSE' && getTopAnswer(contract) === undefined) + (outcomeType === 'FREE_RESPONSE' && getTopAnswer(contract) === undefined) || + outcomeType === 'NUMERIC' ) return ( @@ -96,7 +103,7 @@ export function ContractCard(props: { /> {showQuickBet ? ( - + ) : ( {outcomeType === 'BINARY' && ( diff --git a/web/components/contract/contracts-list.tsx b/web/components/contract/contracts-list.tsx index 019d701e..18718673 100644 --- a/web/components/contract/contracts-list.tsx +++ b/web/components/contract/contracts-list.tsx @@ -19,7 +19,7 @@ export function ContractsGrid(props: { const isBottomVisible = useIsVisible(elem) useEffect(() => { - if (isBottomVisible) { + if (isBottomVisible && hasMore) { loadMore() } }, [isBottomVisible, hasMore, loadMore]) diff --git a/web/components/contract/quick-bet.tsx b/web/components/contract/quick-bet.tsx index c4b1ec16..1c73e40d 100644 --- a/web/components/contract/quick-bet.tsx +++ b/web/components/contract/quick-bet.tsx @@ -14,6 +14,7 @@ import { NumericContract, FreeResponseContract, } from 'common/contract' +import { User } from 'common/user' import { formatLargeNumber, formatMoney, @@ -21,7 +22,6 @@ import { } from 'common/util/format' import { useState } from 'react' import toast from 'react-hot-toast' -import { useUser } from 'web/hooks/use-user' import { useUserContractBets } from 'web/hooks/use-user-bets' import { placeBet } from 'web/lib/firebase/api-call' import { getBinaryProb, getBinaryProbPercent } from 'web/lib/firebase/contracts' @@ -33,11 +33,10 @@ import { useSaveShares } from '../use-save-shares' const BET_SIZE = 10 -export function QuickBet(props: { contract: Contract }) { - const { contract } = props +export function QuickBet(props: { contract: Contract; user: User }) { + const { contract, user } = props - const user = useUser() - const userBets = useUserContractBets(user?.id, contract.id) + const userBets = useUserContractBets(user.id, contract.id) const topAnswer = contract.outcomeType === 'FREE_RESPONSE' ? getTopAnswer(contract as FreeResponseContract) From 90a8de09d772baca927553021c3405e9cd64ff35 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sat, 28 May 2022 15:48:08 -0500 Subject: [PATCH 3/4] Ask a question => Create a question --- web/components/nav/sidebar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index 962593ed..33a84191 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -202,7 +202,7 @@ export default function Sidebar(props: { className?: string }) { {user ? ( ) : ( From 23944bf47a1fdab9eb7f32a3a6077baa040efe57 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sat, 28 May 2022 15:57:12 -0500 Subject: [PATCH 4/4] Filter redemption bets out of market 'Bets' tab --- web/components/feed/activity-items.ts | 4 +--- web/components/feed/contract-activity.tsx | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/web/components/feed/activity-items.ts b/web/components/feed/activity-items.ts index b8d99598..fce2cdc4 100644 --- a/web/components/feed/activity-items.ts +++ b/web/components/feed/activity-items.ts @@ -479,9 +479,7 @@ export function getRecentContractActivityItems( } ) { const { contractPath } = options - bets = bets - .filter((bet) => !bet.isRedemption) - .sort((b1, b2) => b1.createdTime - b2.createdTime) + bets = bets.sort((b1, b2) => b1.createdTime - b2.createdTime) comments = comments.sort((c1, c2) => c1.createdTime - c2.createdTime) const questionItem: QuestionItem = { diff --git a/web/components/feed/contract-activity.tsx b/web/components/feed/contract-activity.tsx index e061f475..a203bfa9 100644 --- a/web/components/feed/contract-activity.tsx +++ b/web/components/feed/contract-activity.tsx @@ -39,7 +39,7 @@ export function ContractActivity(props: { // eslint-disable-next-line react-hooks/rules-of-hooks 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 = mode === 'only-recent'