diff --git a/web/components/contract-search.tsx b/web/components/contract-search.tsx index 8bc1341f..f3bdbd6a 100644 --- a/web/components/contract-search.tsx +++ b/web/components/contract-search.tsx @@ -2,6 +2,7 @@ import algoliasearch from 'algoliasearch/lite' import { Contract } from 'common/contract' +import { User } from 'common/user' import { Sort, useQueryAndSortParams } from '../hooks/use-sort-and-query-params' import { ContractHighlightOptions, @@ -11,7 +12,6 @@ import { Row } from './layout/row' import { useEffect, useMemo, useState } from 'react' import { Spacer } from './layout/spacer' import { ENV, IS_PRIVATE_MANIFOLD } from 'common/envs/constants' -import { useUser } from 'web/hooks/use-user' import { useFollows } from 'web/hooks/use-follows' import { track, trackCallback } from 'web/lib/service/analytics' import ContractSearchFirestore from 'web/pages/contract-search-firestore' @@ -45,6 +45,7 @@ export const DEFAULT_SORT = 'score' type filter = 'personal' | 'open' | 'closed' | 'resolved' | 'all' export function ContractSearch(props: { + user: User | null | undefined querySortOptions?: { defaultSort: Sort defaultFilter?: filter @@ -67,6 +68,7 @@ export function ContractSearch(props: { } }) { const { + user, querySortOptions, additionalFilter, onContractClick, @@ -77,7 +79,6 @@ export function ContractSearch(props: { highlightOptions, } = props - const user = useUser() const memberGroups = (useMemberGroups(user?.id) ?? []).filter( (group) => !NEW_USER_GROUP_SLUGS.includes(group.slug) ) diff --git a/web/components/contract/contracts-grid.tsx b/web/components/contract/contracts-grid.tsx index 77269ea3..f62c3c85 100644 --- a/web/components/contract/contracts-grid.tsx +++ b/web/components/contract/contracts-grid.tsx @@ -97,11 +97,15 @@ export function ContractsGrid(props: { ) } -export function CreatorContractsList(props: { creator: User }) { - const { creator } = props +export function CreatorContractsList(props: { + user: User | null | undefined + creator: User +}) { + const { user, creator } = props return ( , + content: ( + + ), tabIcon: ( {usersContracts.length} diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 8d12e9c0..c35f5d98 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -92,6 +92,7 @@ export default function ContractPage(props: { slug: '', } + const user = useUser() const inIframe = useIsIframe() if (inIframe) { return @@ -103,7 +104,7 @@ export default function ContractPage(props: { return } - return + return } export function ContractPageSidebar(props: { @@ -144,9 +145,12 @@ export function ContractPageSidebar(props: { } export function ContractPageContent( - props: Parameters[0] & { contract: Contract } + props: Parameters[0] & { + contract: Contract + user?: User | null + } ) { - const { backToHome, comments } = props + const { backToHome, comments, user } = props const contract = useContractWithPreload(props.contract) ?? props.contract @@ -164,8 +168,6 @@ export function ContractPageContent( const tips = useTipTxns({ contractId: contract.id }) - const user = useUser() - const { width, height } = useWindowSize() const [showConfetti, setShowConfetti] = useState(false) diff --git a/web/pages/group/[...slugs]/index.tsx b/web/pages/group/[...slugs]/index.tsx index b96d6436..8e7ec19d 100644 --- a/web/pages/group/[...slugs]/index.tsx +++ b/web/pages/group/[...slugs]/index.tsx @@ -201,6 +201,7 @@ export default function GroupPage(props: { const questionsTab = ( { + const user = await getUser(creds.user.uid) + return { props: { user } } +}) -const Home = () => { +const Home = (props: { user: User }) => { + const { user } = props const [contract, setContract] = useContractPage() const router = useRouter() @@ -29,6 +35,7 @@ const Home = () => { { {contract && ( - + ) } diff --git a/web/pages/tag/[tag].tsx b/web/pages/tag/[tag].tsx index 476afecf..c1dce29e 100644 --- a/web/pages/tag/[tag].tsx +++ b/web/pages/tag/[tag].tsx @@ -1,10 +1,12 @@ import { useRouter } from 'next/router' +import { useUser } from 'web/hooks/use-user' import { ContractSearch } from '../../components/contract-search' import { Page } from '../../components/page' import { Title } from '../../components/title' export default function TagPage() { const router = useRouter() + const user = useUser() const { tag } = router.query as { tag: string } if (!router.isReady) return
@@ -12,6 +14,7 @@ export default function TagPage() { <ContractSearch + user={user} querySortOptions={{ defaultSort: 'newest', defaultFilter: 'all',