Prefetch user bets / portfolio data
This commit is contained in:
parent
69df5a947d
commit
3468d8d292
11
web/hooks/use-prefetch.ts
Normal file
11
web/hooks/use-prefetch.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { useUserBetContracts } from './use-contracts'
|
||||
import { usePortfolioHistory } from './use-portfolio-history'
|
||||
import { useUserBets } from './use-user-bets'
|
||||
|
||||
export function usePrefetch(userId: string | undefined) {
|
||||
const maybeUserId = userId ?? ''
|
||||
|
||||
useUserBets(maybeUserId)
|
||||
useUserBetContracts(maybeUserId)
|
||||
usePortfolioHistory(maybeUserId, 'weekly')
|
||||
}
|
|
@ -42,6 +42,7 @@ import {
|
|||
} from 'web/components/contract/contract-leaderboard'
|
||||
import { ContractsGrid } from 'web/components/contract/contracts-grid'
|
||||
import { Title } from 'web/components/title'
|
||||
import { usePrefetch } from 'web/hooks/use-prefetch'
|
||||
|
||||
export const getStaticProps = fromPropz(getStaticPropz)
|
||||
export async function getStaticPropz(props: {
|
||||
|
@ -157,6 +158,7 @@ export function ContractPageContent(
|
|||
const { backToHome, comments, user } = props
|
||||
|
||||
const contract = useContractWithPreload(props.contract) ?? props.contract
|
||||
usePrefetch(user?.id)
|
||||
|
||||
useTracking('view market', {
|
||||
slug: contract.slug,
|
||||
|
|
|
@ -15,6 +15,7 @@ import { track } from 'web/lib/service/analytics'
|
|||
import { authenticateOnServer } from 'web/lib/firebase/server-auth'
|
||||
import { useSaveReferral } from 'web/hooks/use-save-referral'
|
||||
import { GetServerSideProps } from 'next'
|
||||
import { usePrefetch } from 'web/hooks/use-prefetch'
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
const creds = await authenticateOnServer(ctx)
|
||||
|
@ -30,6 +31,7 @@ const Home = (props: { auth: { user: User } | null }) => {
|
|||
useTracking('view home')
|
||||
|
||||
useSaveReferral()
|
||||
usePrefetch(user?.id)
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
Loading…
Reference in New Issue
Block a user