mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-12 13:05:41 +03:00
remove unnecessary get_community calls
This commit is contained in:
parent
4ce2d32860
commit
c41926b93e
@ -28,35 +28,33 @@ const TagContainer = ({
|
||||
style,
|
||||
textStyle,
|
||||
disabled,
|
||||
communityTitle,
|
||||
}) => {
|
||||
const [label, setLabel] = useState(value);
|
||||
const [isCommunity, setIsCommunity] = useState(false);
|
||||
|
||||
console.log(value, communityTitle);
|
||||
useEffect(() => {
|
||||
let isCancelled = false;
|
||||
if (value && /^hive-\d+/.test(value)) {
|
||||
getCommunityTitle(value)
|
||||
.then((r) => {
|
||||
if (!isCancelled) {
|
||||
if (value && /hive-[1-3]\d{4,6}$/.test(value)) {
|
||||
if (communityTitle) {
|
||||
setLabel(communityTitle);
|
||||
setIsCommunity(true);
|
||||
} else {
|
||||
getCommunityTitle(value)
|
||||
.then((r) => {
|
||||
setLabel(r);
|
||||
setIsCommunity(value !== r);
|
||||
return r;
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
if (!isCancelled) {
|
||||
})
|
||||
.catch((e) => {
|
||||
setLabel(value);
|
||||
setIsCommunity(/^hive-\d+/.test(value));
|
||||
setIsCommunity(/hive-[1-3]\d{4,6}$/.test(value));
|
||||
return value;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setLabel(value);
|
||||
setIsCommunity(false);
|
||||
}
|
||||
return () => {
|
||||
isCancelled = true;
|
||||
};
|
||||
});
|
||||
|
||||
// Component Functions
|
||||
|
@ -39,25 +39,25 @@ const PostCardContainer = ({
|
||||
}, [isRefresh]);
|
||||
|
||||
useEffect(() => {
|
||||
if (content) {
|
||||
setActiveVotes(get(content, 'active_votes', []));
|
||||
if (_content) {
|
||||
setActiveVotes(get(_content, 'active_votes', []));
|
||||
|
||||
getPostReblogs(content).then((result) => {
|
||||
getPostReblogs(_content).then((result) => {
|
||||
setReblogs(result);
|
||||
});
|
||||
setContent(content);
|
||||
setContent(_content);
|
||||
}
|
||||
}, [content]);
|
||||
}, [_content]);
|
||||
|
||||
const _handleOnUserPress = () => {
|
||||
if (content && get(currentAccount, 'name') !== get(content, 'author')) {
|
||||
if (_content && get(currentAccount, 'name') !== get(_content, 'author')) {
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.PROFILE,
|
||||
params: {
|
||||
username: get(content, 'author'),
|
||||
reputation: get(content, 'author_reputation'),
|
||||
username: get(_content, 'author'),
|
||||
reputation: get(_content, 'author_reputation'),
|
||||
},
|
||||
key: get(content, 'author'),
|
||||
key: get(_content, 'author'),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -79,9 +79,9 @@ const PostCardContainer = ({
|
||||
routeName: ROUTES.SCREENS.VOTERS,
|
||||
params: {
|
||||
activeVotes,
|
||||
content,
|
||||
content: _content,
|
||||
},
|
||||
key: get(content, 'permlink'),
|
||||
key: get(_content, 'permlink'),
|
||||
});
|
||||
};
|
||||
|
||||
@ -91,12 +91,16 @@ const PostCardContainer = ({
|
||||
params: {
|
||||
reblogs,
|
||||
},
|
||||
key: get(content, 'permlink', get(content, 'author', '')),
|
||||
key: get(_content, 'permlink', get(_content, 'author', '')),
|
||||
});
|
||||
};
|
||||
|
||||
const _fetchPost = async () => {
|
||||
await getPost(get(content, 'author'), get(content, 'permlink'), get(currentAccount, 'username'))
|
||||
await getPost(
|
||||
get(_content, 'author'),
|
||||
get(_content, 'permlink'),
|
||||
get(currentAccount, 'username'),
|
||||
)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
setContent(result);
|
||||
|
@ -102,7 +102,7 @@ const PostCardView = ({
|
||||
profileOnPress={_handleOnUserPress}
|
||||
reputation={get(content, 'author_reputation')}
|
||||
size={36}
|
||||
tag={content.category}
|
||||
content={content}
|
||||
rebloggedBy={rebloggedBy}
|
||||
isPromoted={get(content, 'is_promoted')}
|
||||
/>
|
||||
|
@ -46,6 +46,7 @@ class PostHeaderDescription extends PureComponent {
|
||||
reputation,
|
||||
size,
|
||||
tag,
|
||||
content,
|
||||
tagOnPress,
|
||||
isShowOwnerIndicator,
|
||||
isPromoted,
|
||||
@ -90,6 +91,16 @@ class PostHeaderDescription extends PureComponent {
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.rightContainer}>
|
||||
{!!content && (
|
||||
<TouchableOpacity onPress={() => tagOnPress && tagOnPress()}>
|
||||
<Tag
|
||||
isPostCardTag={!isPromoted}
|
||||
isPin
|
||||
value={content.category}
|
||||
communityTitle={content.community_title}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{!!tag && (
|
||||
<TouchableOpacity onPress={() => tagOnPress && tagOnPress()}>
|
||||
<Tag isPostCardTag={!isPromoted} isPin value={tag} />
|
||||
|
@ -255,7 +255,7 @@ const PostsContainer = ({
|
||||
const filter = type || selectedFilterValue;
|
||||
const subfilter = selectedFeedSubfilterValue;
|
||||
let options = {};
|
||||
const limit = 7;
|
||||
const limit = 5;
|
||||
let func = null;
|
||||
|
||||
if (
|
||||
@ -319,7 +319,7 @@ const PostsContainer = ({
|
||||
_posts = unionBy(posts, _posts, 'permlink');
|
||||
}
|
||||
}
|
||||
if (posts.length <= 7 && pageType !== 'profiles') {
|
||||
if (posts.length <= 5 && pageType !== 'profiles') {
|
||||
_setFeedPosts(_posts);
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ export const getActiveVotes = (author, permlink) =>
|
||||
export const getRankedPosts = async (query, currentUserName, filterNsfw) => {
|
||||
try {
|
||||
let posts = await client.call('bridge', 'get_ranked_posts', query);
|
||||
|
||||
console.log(posts);
|
||||
if (posts) {
|
||||
posts = parsePosts(posts, currentUserName);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user