diff --git a/web/pages/contract-search-firestore.tsx b/web/pages/contract-search-firestore.tsx index 870fa99b..f360f540 100644 --- a/web/pages/contract-search-firestore.tsx +++ b/web/pages/contract-search-firestore.tsx @@ -3,13 +3,18 @@ import { Answer } from 'common/answer' import { searchInAny } from 'common/util/parse' import { sortBy } from 'lodash' import { ContractsGrid } from 'web/components/contract/contracts-grid' -import { useContracts } from 'web/hooks/use-contracts' import { usePersistentState, urlParamStore, } from 'web/hooks/use-persistent-state' import { getProbability } from 'common/calculate' -import { BinaryContract, PseudoNumericContract } from 'common/contract' +import { + BinaryContract, + Contract, + PseudoNumericContract, +} from 'common/contract' +import { useEffect, useState } from 'react' +import { listAllContracts } from 'web/lib/firebase/contracts' const MAX_CONTRACTS_RENDERED = 100 @@ -21,9 +26,10 @@ export default function ContractSearchFirestore(props: { groupSlug?: string } defaultSort?: string + getContracts?: () => Promise }) { - const { additionalFilter } = props - const contracts = useContracts() + const { additionalFilter, getContracts } = props + const [contracts, setContracts] = useState([]) const router = useRouter() const store = urlParamStore(router) const [query, setQuery] = usePersistentState('', { key: 'q', store }) @@ -32,6 +38,15 @@ export default function ContractSearchFirestore(props: { store, }) + useEffect(() => { + // Either set contracts from getContracts, or fallback to getting all of them + if (getContracts) { + getContracts().then(setContracts) + } else { + listAllContracts(100000).then(setContracts) + } + }, [getContracts]) + let matches = (contracts ?? []).filter((c) => searchInAny( query, diff --git a/web/pages/group/[...slugs]/index.tsx b/web/pages/group/[...slugs]/index.tsx index c7bccbfe..674190a8 100644 --- a/web/pages/group/[...slugs]/index.tsx +++ b/web/pages/group/[...slugs]/index.tsx @@ -227,6 +227,10 @@ export default function GroupPage(props: { { + const contracts = await listContractsByGroupSlug(group.slug) + return contracts.filter((c) => !c.isResolved) + }} /> ) : (