Publicly display bets without infinite looping

React why
This commit is contained in:
Austin Chen 2022-05-31 18:06:27 -07:00
parent c8bf71d40d
commit a840143990
2 changed files with 30 additions and 11 deletions

View File

@ -54,9 +54,14 @@ import { SellSharesModal } from './sell-modal'
type BetSort = 'newest' | 'profit' | 'closeTime' | 'value' type BetSort = 'newest' | 'profit' | 'closeTime' | 'value'
type BetFilter = 'open' | 'sold' | 'closed' | 'resolved' | 'all' type BetFilter = 'open' | 'sold' | 'closed' | 'resolved' | 'all'
export function BetsList(props: { user: User }) { export function BetsList(props: { user: User; hideBetsBefore?: number }) {
const { user } = props const { user, hideBetsBefore } = props
const bets = useUserBets(user.id, { includeRedemptions: true }) const allBets = useUserBets(user.id, { includeRedemptions: true })
// Hide bets before 06-01-2022 if this isn't your own profile
// NOTE: This means public profits also begin on 06-01-2022 as well.
const bets = (allBets ?? []).filter(
(bet) => bet.createdTime >= (hideBetsBefore ?? 0)
)
const [contracts, setContracts] = useState<Contract[] | undefined>() const [contracts, setContracts] = useState<Contract[] | undefined>()
const [sort, setSort] = useState<BetSort>('newest') const [sort, setSort] = useState<BetSort>('newest')
@ -77,7 +82,7 @@ export function BetsList(props: { user: User }) {
disposed = true disposed = true
} }
} }
}, [bets]) }, [allBets])
const getTime = useTimeSinceFirstRender() const getTime = useTimeSinceFirstRender()
useEffect(() => { useEffect(() => {

View File

@ -44,6 +44,7 @@ export function UserLink(props: {
} }
export const TAB_IDS = ['markets', 'comments', 'bets'] export const TAB_IDS = ['markets', 'comments', 'bets']
const JUNE_1_2022 = new Date('2022-06-01T00:00:00.000Z').valueOf()
export function UserPage(props: { export function UserPage(props: {
user: User user: User
@ -229,14 +230,27 @@ export function UserPage(props: {
title: 'Bets', title: 'Bets',
content: ( content: (
<div> <div>
<AlertBox {isCurrentUser && (
title="Bets are becoming publicly visible on 2022-06-01" <AlertBox
text="Bettor identities have always been traceable through the Manifold API. title="Bets after 2022-06-01 are publicly visible by default."
However, our interface implied that they were private. text="Note that all historical bets are also publicly accessible through the API.
As we develop new features such as leaderboards and bet history, it won't be technically feasible to keep this info private. See: https://manifold.markets/Austin/will-all-bets-on-manifold-be-public"
For more context, or if you'd like to wipe your bet history, see: https://manifold.markets/Austin/will-all-bets-on-manifold-be-public" />
)}
<BetsList
user={user}
hideBetsBefore={isCurrentUser ? 0 : JUNE_1_2022}
/> />
{isCurrentUser && <BetsList user={user} />} {!isCurrentUser && (
<>
<Spacer h={4} />
<AlertBox
title="Bets before 2022-06-01 are hidden by default."
text="Note that all historical bets are also publicly accessible through the API.
See: https://manifold.markets/Austin/will-all-bets-on-manifold-be-public"
/>
</>
)}
</div> </div>
), ),
tabIcon: ( tabIcon: (