mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-02 02:31:41 +03:00
Merge pull request #1728 from ecency/bugfix/community
Fixed community search bug
This commit is contained in:
commit
ee792b139e
@ -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,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
@ -25,6 +25,7 @@ const CommunitiesScreen = ({ navigation, searchValue }) => {
|
||||
handleOnPress,
|
||||
handleSubscribeButtonPress,
|
||||
isLoggedIn,
|
||||
noResult,
|
||||
}) => (
|
||||
<>
|
||||
<FilterBar
|
||||
@ -46,6 +47,7 @@ const CommunitiesScreen = ({ navigation, searchValue }) => {
|
||||
handleOnPress={handleOnPress}
|
||||
handleSubscribeButtonPress={handleSubscribeButtonPress}
|
||||
isLoggedIn={isLoggedIn}
|
||||
noResult={noResult}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
@ -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 (
|
||||
<SafeAreaView style={styles.container}>
|
||||
<FlatList
|
||||
data={votes}
|
||||
keyExtractor={(item) => item.id.toString()}
|
||||
renderItem={({ item, index }) => _renderItem(item, index)}
|
||||
ListEmptyComponent={_renderEmptyContent}
|
||||
/>
|
||||
{!noResult && (
|
||||
<FlatList
|
||||
data={votes}
|
||||
keyExtractor={(item) => item.id.toString()}
|
||||
renderItem={({ item, index }) => _renderItem(item, index)}
|
||||
ListEmptyComponent={_renderEmptyContent}
|
||||
/>
|
||||
)}
|
||||
</SafeAreaView>
|
||||
);
|
||||
};
|
||||
|
@ -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 }) => {
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.stats}>
|
||||
{item.payout && <Text style={styles.postIconText}>{`$ ${item.payout}`}</Text>}
|
||||
{!isUndefined(item.payout) && (
|
||||
<Text style={styles.postIconText}>{`$ ${item.payout}`}</Text>
|
||||
)}
|
||||
<TextWithIcon
|
||||
iconName="heart-outline"
|
||||
textStyle={styles.postIconText}
|
||||
|
Loading…
Reference in New Issue
Block a user