mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-12 13:05:41 +03:00
searchResults bug fix stuff
This commit is contained in:
parent
563618e173
commit
0b3368eb4e
@ -17,34 +17,40 @@ const PostsResultsContainer = ({ children, navigation, searchValue, currentAccou
|
||||
setData([]);
|
||||
|
||||
if (searchValue) {
|
||||
search({ q: searchValue, sort }).then((res) => {
|
||||
setScrollId(res.scroll_id);
|
||||
setData(res.results);
|
||||
});
|
||||
} else {
|
||||
getPromotePosts()
|
||||
.then((result) => {
|
||||
return Promise.all(
|
||||
result.map((item) =>
|
||||
getPost(
|
||||
get(item, 'author'),
|
||||
get(item, 'permlink'),
|
||||
currentAccountUsername,
|
||||
true,
|
||||
).then((post) => {
|
||||
post.author_rep = post.author_reputation;
|
||||
post.body = (post.summary && post.summary.substring(0, 130)) || '';
|
||||
return post;
|
||||
}),
|
||||
),
|
||||
);
|
||||
search({ q: searchValue, sort })
|
||||
.then((res) => {
|
||||
setScrollId(res.scroll_id);
|
||||
setData(res.results);
|
||||
})
|
||||
.then((result) => {
|
||||
setData(result);
|
||||
});
|
||||
.catch((err) => console.log(err, 'search error'));
|
||||
} else {
|
||||
getInitialPosts().then((res) => {
|
||||
console.log(res, 'res');
|
||||
// setData(res);
|
||||
});
|
||||
}
|
||||
}, [searchValue, sort]);
|
||||
|
||||
const getInitialPosts = async () => {
|
||||
const promoteds = await getPromotePosts();
|
||||
|
||||
return await Promise.all(
|
||||
promoteds.map(async (item) => {
|
||||
const post = await getPost(
|
||||
get(item, 'author'),
|
||||
get(item, 'permlink'),
|
||||
currentAccountUsername,
|
||||
true,
|
||||
);
|
||||
|
||||
post.author_rep = post.author_reputation;
|
||||
post.body = (post.summary && post.summary.substring(0, 130)) || '';
|
||||
// return await call to your function
|
||||
return post;
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
// Component Functions
|
||||
|
||||
const _handleOnPress = (item) => {
|
||||
|
@ -7,6 +7,7 @@ import ROUTES from '../../../constants/routeNames';
|
||||
|
||||
import { getTrendingTags } from '../../../providers/hive/dhive';
|
||||
import { getLeaderboard } from '../../../providers/ecency/ecency';
|
||||
import { isCommunity } from '../../../utils/communityValidation';
|
||||
|
||||
const OtherResultContainer = (props) => {
|
||||
const [tags, setTags] = useState([]);
|
||||
@ -17,7 +18,9 @@ const OtherResultContainer = (props) => {
|
||||
setTags([]);
|
||||
|
||||
getTrendingTags(searchValue).then((res) => {
|
||||
setTags(res);
|
||||
const data = res.filter((item) => !isCommunity(item.name));
|
||||
console.log(data, 'data');
|
||||
setTags(data);
|
||||
});
|
||||
}, [searchValue]);
|
||||
|
||||
|
@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import { View, SafeAreaView } from 'react-native';
|
||||
import ScrollableTabView from 'react-native-scrollable-tab-view';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
// Components
|
||||
import { SearchInput, TabBar } from '../../../components';
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { isNumber } from 'lodash';
|
||||
|
||||
export const isCommunity = (text) => {
|
||||
if (/^hive-\d+/.test(text) && text.length === 11) {
|
||||
if (/^hive-\d+/.test(text) && text.length === 11 && isNumber(Number(text.split('-')[1]))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user