Always show follow a community prompt

This commit is contained in:
James Grugett 2022-02-06 20:03:42 -06:00
parent ab6cfd2564
commit faa49b750e

View File

@ -62,9 +62,9 @@ const Home = (props: {
contracts.map((contract, index) => [contract.id, index]) contracts.map((contract, index) => [contract.id, index])
) )
const followedFoldIds = useFollowedFolds(user) ?? [] const followedFoldIds = useFollowedFolds(user)
const followedFolds = filterDefined( const followedFolds = filterDefined(
followedFoldIds.map((id) => folds.find((fold) => fold.id === id)) (followedFoldIds ?? []).map((id) => folds.find((fold) => fold.id === id))
) )
const tagSet = new Set( const tagSet = new Set(
_.flatten(followedFolds.map((fold) => fold.lowercaseTags)) _.flatten(followedFolds.map((fold) => fold.lowercaseTags))
@ -75,15 +75,17 @@ const Home = (props: {
? new Set(yourBetContractIds) ? new Set(yourBetContractIds)
: undefined : undefined
// By default, show all contracts // Show no contracts before your info is loaded.
let feedContracts = contracts let feedContracts: Contract[] = []
// If the user is following any folds, then exclude all other contracts if (yourBetContracts && followedFoldIds) {
if (yourBetContracts && followedFoldIds.length > 0) { // Show all contracts if no folds are followed.
feedContracts = contracts.filter( if (followedFoldIds.length === 0) feedContracts = contracts
(contract) => else
contract.lowercaseTags.some((tag) => tagSet.has(tag)) || feedContracts = contracts.filter(
yourBetContracts.has(contract.id) (contract) =>
) contract.lowercaseTags.some((tag) => tagSet.has(tag)) ||
yourBetContracts.has(contract.id)
)
} }
const oneDayMS = 24 * 60 * 60 * 1000 const oneDayMS = 24 * 60 * 60 * 1000
@ -145,17 +147,13 @@ const Home = (props: {
<Row className="text-sm text-gray-800 mx-3 mb-3 gap-2 items-center"> <Row className="text-sm text-gray-800 mx-3 mb-3 gap-2 items-center">
<SparklesIcon className="inline w-5 h-5" aria-hidden="true" /> <SparklesIcon className="inline w-5 h-5" aria-hidden="true" />
Recent activity Recent activity
{followedFoldIds.length === 0 ? ( <span></span>
<> <span>
<span></span> <SiteLink href="/folds" className="font-semibold">
<span> follow a community
<SiteLink href="/folds" className="font-semibold"> </SiteLink>{' '}
follow a community to personalize
</SiteLink>{' '} </span>
to personalize
</span>
</>
) : null}
</Row> </Row>
{activeContracts ? ( {activeContracts ? (