Remove unnecessary cruft from contract page props
This commit is contained in:
parent
240c94a1d1
commit
68c2a73950
|
@ -54,7 +54,7 @@ export const getStaticProps = fromPropz(getStaticPropz)
|
||||||
export async function getStaticPropz(props: {
|
export async function getStaticPropz(props: {
|
||||||
params: { username: string; contractSlug: string }
|
params: { username: string; contractSlug: string }
|
||||||
}) {
|
}) {
|
||||||
const { username, contractSlug } = props.params
|
const { contractSlug } = props.params
|
||||||
const contract = (await getContractFromSlug(contractSlug)) || null
|
const contract = (await getContractFromSlug(contractSlug)) || null
|
||||||
const contractId = contract?.id
|
const contractId = contract?.id
|
||||||
|
|
||||||
|
@ -66,8 +66,6 @@ export async function getStaticPropz(props: {
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
contract,
|
contract,
|
||||||
username,
|
|
||||||
slug: contractSlug,
|
|
||||||
// Limit the data sent to the client. Client will still load all bets and comments directly.
|
// Limit the data sent to the client. Client will still load all bets and comments directly.
|
||||||
bets: bets.slice(0, 5000),
|
bets: bets.slice(0, 5000),
|
||||||
comments: comments.slice(0, 1000),
|
comments: comments.slice(0, 1000),
|
||||||
|
@ -83,18 +81,14 @@ export async function getStaticPaths() {
|
||||||
|
|
||||||
export default function ContractPage(props: {
|
export default function ContractPage(props: {
|
||||||
contract: Contract | null
|
contract: Contract | null
|
||||||
username: string
|
|
||||||
bets: Bet[]
|
bets: Bet[]
|
||||||
comments: ContractComment[]
|
comments: ContractComment[]
|
||||||
slug: string
|
|
||||||
backToHome?: () => void
|
backToHome?: () => void
|
||||||
}) {
|
}) {
|
||||||
props = usePropz(props, getStaticPropz) ?? {
|
props = usePropz(props, getStaticPropz) ?? {
|
||||||
contract: null,
|
contract: null,
|
||||||
username: '',
|
|
||||||
comments: [],
|
comments: [],
|
||||||
bets: [],
|
bets: [],
|
||||||
slug: '',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
@ -228,7 +222,7 @@ export function ContractPageContent(
|
||||||
<SEO
|
<SEO
|
||||||
title={question}
|
title={question}
|
||||||
description={ogCardProps.description}
|
description={ogCardProps.description}
|
||||||
url={`/${props.username}/${props.slug}`}
|
url={`/${contract.creatorUsername}/${contract.slug}`}
|
||||||
ogCardProps={ogCardProps}
|
ogCardProps={ogCardProps}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -34,20 +34,14 @@ export const getStaticProps = fromPropz(getStaticPropz)
|
||||||
export async function getStaticPropz(props: {
|
export async function getStaticPropz(props: {
|
||||||
params: { username: string; contractSlug: string }
|
params: { username: string; contractSlug: string }
|
||||||
}) {
|
}) {
|
||||||
const { username, contractSlug } = props.params
|
const { contractSlug } = props.params
|
||||||
const contract = (await getContractFromSlug(contractSlug)) || null
|
const contract = (await getContractFromSlug(contractSlug)) || null
|
||||||
const contractId = contract?.id
|
const contractId = contract?.id
|
||||||
|
|
||||||
const bets = contractId ? await listAllBets(contractId) : []
|
const bets = contractId ? await listAllBets(contractId) : []
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: { contract, bets },
|
||||||
contract,
|
|
||||||
username,
|
|
||||||
slug: contractSlug,
|
|
||||||
bets,
|
|
||||||
},
|
|
||||||
|
|
||||||
revalidate: 60, // regenerate after a minute
|
revalidate: 60, // regenerate after a minute
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,15 +52,11 @@ export async function getStaticPaths() {
|
||||||
|
|
||||||
export default function ContractEmbedPage(props: {
|
export default function ContractEmbedPage(props: {
|
||||||
contract: Contract | null
|
contract: Contract | null
|
||||||
username: string
|
|
||||||
bets: Bet[]
|
bets: Bet[]
|
||||||
slug: string
|
|
||||||
}) {
|
}) {
|
||||||
props = usePropz(props, getStaticPropz) ?? {
|
props = usePropz(props, getStaticPropz) ?? {
|
||||||
contract: null,
|
contract: null,
|
||||||
username: '',
|
|
||||||
bets: [],
|
bets: [],
|
||||||
slug: '',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const contract = useContractWithPreload(props.contract)
|
const contract = useContractWithPreload(props.contract)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user