aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-03-08 16:11:33 -0500
committerIvan Chen <ivan@tagg.id>2021-03-08 16:11:33 -0500
commit8837ea74dbff9cf455cd7cb092767e51de3900f8 (patch)
tree1f1b1c9bfe087a9ce4d23050ccab9fa09708da7c
parent7657657c2b8a28b96962ac4fa816bb1625a36e4b (diff)
fix single category result not showing up
-rw-r--r--src/components/search/SearchResultList.tsx16
1 files changed, 6 insertions, 10 deletions
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<SearchResultsProps> = ({
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<SearchResultsProps> = ({
/>
);
}}
- 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)
+ }
/>
)}
</View>