Move contract hook back into ContractPageContent. (Fixes going back to home.)
This commit is contained in:
		
							parent
							
								
									05f1da430c
								
							
						
					
					
						commit
						dcaddd6a1a
					
				|  | @ -86,13 +86,13 @@ export default function ContractPage(props: { | ||||||
|     slug: '', |     slug: '', | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   const contract = useContractWithPreload(props.contract) |  | ||||||
| 
 |  | ||||||
|   const inIframe = useIsIframe() |   const inIframe = useIsIframe() | ||||||
|   if (inIframe) { |   if (inIframe) { | ||||||
|     return <ContractEmbedPage {...props} /> |     return <ContractEmbedPage {...props} /> | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   const { contract } = props | ||||||
|  | 
 | ||||||
|   if (!contract) { |   if (!contract) { | ||||||
|     return <Custom404 /> |     return <Custom404 /> | ||||||
|   } |   } | ||||||
|  | @ -103,7 +103,9 @@ export default function ContractPage(props: { | ||||||
| export function ContractPageContent( | export function ContractPageContent( | ||||||
|   props: Parameters<typeof ContractPage>[0] & { contract: Contract } |   props: Parameters<typeof ContractPage>[0] & { contract: Contract } | ||||||
| ) { | ) { | ||||||
|   const { contract, backToHome, comments } = props |   const { backToHome, comments } = props | ||||||
|  | 
 | ||||||
|  |   const contract = useContractWithPreload(props.contract) ?? props.contract | ||||||
| 
 | 
 | ||||||
|   const bets = useBets(contract.id) ?? props.bets |   const bets = useBets(contract.id) ?? props.bets | ||||||
|   // Sort for now to see if bug is fixed.
 |   // Sort for now to see if bug is fixed.
 | ||||||
|  |  | ||||||
|  | @ -9,7 +9,6 @@ import { ContractSearch } from 'web/components/contract-search' | ||||||
| import { Contract } from 'common/contract' | import { Contract } from 'common/contract' | ||||||
| import { ContractPageContent } from './[username]/[contractSlug]' | import { ContractPageContent } from './[username]/[contractSlug]' | ||||||
| import { getContractFromSlug } from 'web/lib/firebase/contracts' | import { getContractFromSlug } from 'web/lib/firebase/contracts' | ||||||
| import { useContractWithPreload } from 'web/hooks/use-contract' |  | ||||||
| 
 | 
 | ||||||
| const Home = () => { | const Home = () => { | ||||||
|   const user = useUser() |   const user = useUser() | ||||||
|  | @ -105,9 +104,7 @@ const useContractPage = () => { | ||||||
|     if (contract) window.scrollTo(0, 0) |     if (contract) window.scrollTo(0, 0) | ||||||
|   }, [contract]) |   }, [contract]) | ||||||
| 
 | 
 | ||||||
|   const updatedContract = useContractWithPreload(contract) |   return [contract, setContract] as const | ||||||
| 
 |  | ||||||
|   return [updatedContract, setContract] as const |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default Home | export default Home | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user