From faa49b750e516a7eb7cf134e6c7b88944bf333ee Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sun, 6 Feb 2022 20:03:42 -0600 Subject: [PATCH] Always show follow a community prompt --- web/pages/home.tsx | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/web/pages/home.tsx b/web/pages/home.tsx index e3f32169..898f02ce 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -62,9 +62,9 @@ const Home = (props: { contracts.map((contract, index) => [contract.id, index]) ) - const followedFoldIds = useFollowedFolds(user) ?? [] + const followedFoldIds = useFollowedFolds(user) 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( _.flatten(followedFolds.map((fold) => fold.lowercaseTags)) @@ -75,15 +75,17 @@ const Home = (props: { ? new Set(yourBetContractIds) : undefined - // By default, show all contracts - let feedContracts = contracts - // If the user is following any folds, then exclude all other contracts - if (yourBetContracts && followedFoldIds.length > 0) { - feedContracts = contracts.filter( - (contract) => - contract.lowercaseTags.some((tag) => tagSet.has(tag)) || - yourBetContracts.has(contract.id) - ) + // Show no contracts before your info is loaded. + let feedContracts: Contract[] = [] + if (yourBetContracts && followedFoldIds) { + // Show all contracts if no folds are followed. + if (followedFoldIds.length === 0) feedContracts = contracts + else + feedContracts = contracts.filter( + (contract) => + contract.lowercaseTags.some((tag) => tagSet.has(tag)) || + yourBetContracts.has(contract.id) + ) } const oneDayMS = 24 * 60 * 60 * 1000 @@ -145,17 +147,13 @@ const Home = (props: { {activeContracts ? (