From 68c2a73950cbe70c7438481c1b2e6b63cade87bb Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 20 Sep 2022 21:21:23 -0700 Subject: [PATCH] Remove unnecessary cruft from contract page props --- web/pages/[username]/[contractSlug].tsx | 10 ++-------- web/pages/embed/[username]/[contractSlug].tsx | 14 ++------------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 3682e700..a4686fdf 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -54,7 +54,7 @@ export const getStaticProps = fromPropz(getStaticPropz) export async function getStaticPropz(props: { params: { username: string; contractSlug: string } }) { - const { username, contractSlug } = props.params + const { contractSlug } = props.params const contract = (await getContractFromSlug(contractSlug)) || null const contractId = contract?.id @@ -66,8 +66,6 @@ export async function getStaticPropz(props: { return { props: { contract, - username, - slug: contractSlug, // Limit the data sent to the client. Client will still load all bets and comments directly. bets: bets.slice(0, 5000), comments: comments.slice(0, 1000), @@ -83,18 +81,14 @@ export async function getStaticPaths() { export default function ContractPage(props: { contract: Contract | null - username: string bets: Bet[] comments: ContractComment[] - slug: string backToHome?: () => void }) { props = usePropz(props, getStaticPropz) ?? { contract: null, - username: '', comments: [], bets: [], - slug: '', } const user = useUser() @@ -228,7 +222,7 @@ export function ContractPageContent( )} diff --git a/web/pages/embed/[username]/[contractSlug].tsx b/web/pages/embed/[username]/[contractSlug].tsx index 62dd1ae1..58a7e063 100644 --- a/web/pages/embed/[username]/[contractSlug].tsx +++ b/web/pages/embed/[username]/[contractSlug].tsx @@ -34,20 +34,14 @@ export const getStaticProps = fromPropz(getStaticPropz) export async function getStaticPropz(props: { params: { username: string; contractSlug: string } }) { - const { username, contractSlug } = props.params + const { contractSlug } = props.params const contract = (await getContractFromSlug(contractSlug)) || null const contractId = contract?.id const bets = contractId ? await listAllBets(contractId) : [] return { - props: { - contract, - username, - slug: contractSlug, - bets, - }, - + props: { contract, bets }, revalidate: 60, // regenerate after a minute } } @@ -58,15 +52,11 @@ export async function getStaticPaths() { export default function ContractEmbedPage(props: { contract: Contract | null - username: string bets: Bet[] - slug: string }) { props = usePropz(props, getStaticPropz) ?? { contract: null, - username: '', bets: [], - slug: '', } const contract = useContractWithPreload(props.contract)