From 8837ea74dbff9cf455cd7cb092767e51de3900f8 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 8 Mar 2021 16:11:33 -0500 Subject: fix single category result not showing up --- src/components/search/SearchResultList.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/components/search/SearchResultList.tsx b/src/components/search/SearchResultList.tsx index 32caa764..fe32ef65 100644 --- a/src/components/search/SearchResultList.tsx +++ b/src/components/search/SearchResultList.tsx @@ -25,14 +25,15 @@ const SearchResultList: React.FC = ({ results, keyboardVisible, }) => { - const [showSection, setShowSection] = useState(true); const [showEmptyView, setshowEmptyView] = useState(false); const {user: loggedInUser} = useSelector((state: RootState) => state.user); useEffect(() => { if (results && results.length > 0) { setshowEmptyView( - results[0].data.length === 0 && results[1].data.length === 0, + results[0].data.length === 0 && + results[1].data.length === 0 && + results[2].data.length === 0, ); } }, [results]); @@ -62,14 +63,9 @@ const SearchResultList: React.FC = ({ /> ); }} - renderSectionHeader={({section: {title, data}}) => { - if (['categories', 'badges'].includes(title) && data.length === 0) { - setShowSection(false); - } - return sectionHeader( - ['users', 'categories'].includes(title) && showSection, - ); - }} + renderSectionHeader={({section: {data}}) => + sectionHeader(data.length !== 0) + } /> )} -- cgit v1.2.3-70-g09d2