diff --git a/src/screens/searchResult/container/communitiesContainer.js b/src/screens/searchResult/container/communitiesContainer.js index 2dee04344..ca5c164f0 100644 --- a/src/screens/searchResult/container/communitiesContainer.js +++ b/src/screens/searchResult/container/communitiesContainer.js @@ -1,6 +1,7 @@ import { useState, useEffect } from 'react'; import { withNavigation } from 'react-navigation'; import { connect } from 'react-redux'; +import isEmpty from 'lodash/isEmpty'; import ROUTES from '../../../constants/routeNames'; @@ -20,12 +21,16 @@ const CommunitiesContainer = ({ const [query, setQuery] = useState(''); const [sort, setSort] = useState('rank'); const [allSubscriptions, setAllSubscriptions] = useState([]); + const [noResult, setNoResult] = useState(false); useEffect(() => { setData([]); getCommunities('', 100, query, sort).then((res) => { - if (res) { + if (!isEmpty(res)) { setData(res); + setNoResult(false); + } else { + setNoResult(true); } }); }, [query, sort]); @@ -33,6 +38,7 @@ const CommunitiesContainer = ({ useEffect(() => { setData([]); setQuery(searchValue); + setNoResult(false); }, [searchValue]); useEffect(() => { @@ -74,6 +80,7 @@ const CommunitiesContainer = ({ handleOnPress: _handleOnPress, handleSubscribeButtonPress: _handleSubscribeButtonPress, isLoggedIn, + noResult, }) ); }; diff --git a/src/screens/searchResult/screen/communities.js b/src/screens/searchResult/screen/communities.js index 7f3c35895..1c4633e9b 100644 --- a/src/screens/searchResult/screen/communities.js +++ b/src/screens/searchResult/screen/communities.js @@ -25,6 +25,7 @@ const CommunitiesScreen = ({ navigation, searchValue }) => { handleOnPress, handleSubscribeButtonPress, isLoggedIn, + noResult, }) => ( <> { handleOnPress={handleOnPress} handleSubscribeButtonPress={handleSubscribeButtonPress} isLoggedIn={isLoggedIn} + noResult={noResult} /> )} diff --git a/src/screens/searchResult/screen/communitiesList.js b/src/screens/searchResult/screen/communitiesList.js index b61eb7c14..90e7f82e4 100644 --- a/src/screens/searchResult/screen/communitiesList.js +++ b/src/screens/searchResult/screen/communitiesList.js @@ -14,6 +14,7 @@ const VotersDisplayView = ({ handleSubscribeButtonPress, allSubscriptions, isLoggedIn, + noResult, }) => { const _renderItem = (item, index) => { const isSubscribed = allSubscriptions.some((sub) => sub[0] === item.name); @@ -54,12 +55,14 @@ const VotersDisplayView = ({ return ( - item.id.toString()} - renderItem={({ item, index }) => _renderItem(item, index)} - ListEmptyComponent={_renderEmptyContent} - /> + {!noResult && ( + item.id.toString()} + renderItem={({ item, index }) => _renderItem(item, index)} + ListEmptyComponent={_renderEmptyContent} + /> + )} ); }; diff --git a/src/screens/searchResult/screen/postResult.js b/src/screens/searchResult/screen/postResult.js index 937c3fa07..08fba5e23 100644 --- a/src/screens/searchResult/screen/postResult.js +++ b/src/screens/searchResult/screen/postResult.js @@ -1,6 +1,7 @@ import React from 'react'; import { SafeAreaView, FlatList, View, Text, TouchableOpacity } from 'react-native'; import get from 'lodash/get'; +import isUndefined from 'lodash/isUndefined'; import FastImage from 'react-native-fast-image'; import { useIntl } from 'react-intl'; @@ -38,7 +39,9 @@ const PostResult = ({ navigation, searchValue }) => { - {item.payout && {`$ ${item.payout}`}} + {!isUndefined(item.payout) && ( + {`$ ${item.payout}`} + )}