import React from 'react' import Router from 'next/router' import { Contract } from '../lib/firebase/contracts' import { Page } from '../components/page' import { ActivityFeed } from './activity' import { Comment } from '../lib/firebase/comments' import { Bet } from '../lib/firebase/bets' import FeedCreate from '../components/feed-create' import { Spacer } from '../components/layout/spacer' import { Col } from '../components/layout/col' import { useUser } from '../hooks/use-user' import { Fold } from '../../common/fold' import { LoadingIndicator } from '../components/loading-indicator' import { Row } from '../components/layout/row' import { SparklesIcon } from '@heroicons/react/solid' import { FastFoldFollowing } from '../components/fast-fold-following' import { getAllContractInfo, useActiveContracts, } from '../hooks/use-active-contracts' export async function getStaticProps() { const contractInfo = await getAllContractInfo() return { props: contractInfo, revalidate: 60, // regenerate after a minute } } const Home = (props: { contracts: Contract[] folds: Fold[] recentBets: Bet[] recentComments: Comment[] }) => { const user = useUser() const { activeContracts, activeBets, activeComments, initialFollowedFoldSlugs, } = useActiveContracts(props, user) if (user === null) { Router.replace('/') return <> } return ( {initialFollowedFoldSlugs !== undefined && initialFollowedFoldSlugs.length === 0 && ( )} {activeContracts ? ( ) : ( )} ) } export default Home