Local search filters on groups, exclude contractIds

This commit is contained in:
James Grugett 2022-08-05 12:01:16 -07:00
parent 60ebadbbe5
commit ced404eb74

View File

@ -20,6 +20,8 @@ export default function ContractSearchFirestore(props: {
additionalFilter?: {
creatorId?: string
tag?: string
excludeContractIds?: string[]
groupSlug?: string
}
}) {
const contracts = useContracts()
@ -63,7 +65,7 @@ export default function ContractSearchFirestore(props: {
}
if (additionalFilter) {
const { creatorId, tag } = additionalFilter
const { creatorId, tag, groupSlug, excludeContractIds } = additionalFilter
if (creatorId) {
matches = matches.filter((c) => c.creatorId === creatorId)
@ -74,6 +76,14 @@ export default function ContractSearchFirestore(props: {
c.lowercaseTags.includes(tag.toLowerCase())
)
}
if (groupSlug) {
matches = matches.filter((c) => c.groupSlugs?.includes(groupSlug))
}
if (excludeContractIds) {
matches = matches.filter((c) => !excludeContractIds.includes(c.id))
}
}
matches = matches.slice(0, MAX_CONTRACTS_RENDERED)