mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 20:31:37 +03:00
Added reblog count for posts
This commit is contained in:
parent
5c5d5b58f4
commit
fb50636d23
@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
// Dsteem
|
||||
// Services
|
||||
import { getPost } from '../../../providers/steem/dsteem';
|
||||
|
||||
import PostCardView from '../view/postCardView';
|
||||
|
@ -15,12 +15,7 @@ export default EStyleSheet.create({
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
flexDirection: 'row',
|
||||
},
|
||||
comment: {
|
||||
alignSelf: 'center',
|
||||
fontSize: 10,
|
||||
marginLeft: 3,
|
||||
color: '$iconColor',
|
||||
alignSelf: 'flex-end',
|
||||
},
|
||||
commentIcon: {
|
||||
alignSelf: 'flex-start',
|
||||
@ -28,6 +23,7 @@ export default EStyleSheet.create({
|
||||
color: '$iconColor',
|
||||
margin: 0,
|
||||
width: 20,
|
||||
marginLeft: 25,
|
||||
},
|
||||
postBodyWrapper: {
|
||||
marginHorizontal: 9,
|
||||
@ -60,7 +56,6 @@ export default EStyleSheet.create({
|
||||
backgroundColor: '$primaryBackgroundColor',
|
||||
flexDirection: 'row',
|
||||
margin: 16,
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
bodyHeader: {
|
||||
backgroundColor: '$primaryBackgroundColor',
|
||||
@ -70,7 +65,14 @@ export default EStyleSheet.create({
|
||||
marginBottom: 12,
|
||||
},
|
||||
leftFooterWrapper: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'flex-start',
|
||||
},
|
||||
rightFooterWrapper: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'flex-end',
|
||||
},
|
||||
dropdownWrapper: {
|
||||
position: 'absolute',
|
||||
|
@ -10,7 +10,6 @@ import { getTimeFromNow } from '../../../utils/time';
|
||||
// Components
|
||||
import { PostHeaderDescription } from '../../postElements';
|
||||
import { PostDropdown } from '../../postDropdown';
|
||||
import { Icon } from '../../icon';
|
||||
import { TextWithIcon } from '../../basicUIElements';
|
||||
|
||||
// STEEM
|
||||
@ -130,17 +129,30 @@ class PostCardView extends Component {
|
||||
<View style={styles.leftFooterWrapper}>
|
||||
<Upvote fetchPost={fetchPost} isShowPayoutValue content={content} />
|
||||
<TouchableOpacity style={styles.commentButton} onPress={this._handleOnVotersPress}>
|
||||
<Icon
|
||||
style={[styles.commentIcon, { marginLeft: 25 }]}
|
||||
<TextWithIcon
|
||||
iconName="people"
|
||||
iconStyle={styles.commentIcon}
|
||||
iconType="MaterialIcons"
|
||||
name="people"
|
||||
isClickable
|
||||
text={get(content, 'vote_count', 0)}
|
||||
/>
|
||||
<Text style={styles.comment}>{get(content, 'vote_count', 0)}</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<View style={styles.commentButton}>
|
||||
<Icon style={[styles.commentIcon]} iconType="MaterialIcons" name="comment" />
|
||||
<Text style={styles.comment}>{get(content, 'children')}</Text>
|
||||
<View style={styles.rightFooterWrapper}>
|
||||
<TextWithIcon
|
||||
iconName="repeat"
|
||||
iconStyle={styles.commentIcon}
|
||||
iconType="MaterialIcons"
|
||||
isClickable
|
||||
text={get(content, 'reblogCount', 0)}
|
||||
/>
|
||||
<TextWithIcon
|
||||
iconName="comment"
|
||||
iconStyle={styles.commentIcon}
|
||||
iconType="MaterialIcons"
|
||||
isClickable
|
||||
text={get(content, 'vote_count', 0)}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
@ -85,7 +85,7 @@ class PostDisplayView extends PureComponent {
|
||||
iconType="MaterialIcons"
|
||||
isClickable
|
||||
onPress={() => handleOnVotersPress && handleOnVotersPress(get(post, 'active_votes'))}
|
||||
text={get(post, 'vote_count')}
|
||||
text={get(post, 'vote_count', 0)}
|
||||
textMarginLeft={20}
|
||||
/>
|
||||
<TextWithIcon
|
||||
@ -93,7 +93,15 @@ class PostDisplayView extends PureComponent {
|
||||
iconStyle={styles.barIcons}
|
||||
iconType="MaterialIcons"
|
||||
isClickable
|
||||
text={get(post, 'children')}
|
||||
text={get(post, 'children', 0)}
|
||||
textMarginLeft={20}
|
||||
/>
|
||||
<TextWithIcon
|
||||
iconName="repeat"
|
||||
iconStyle={styles.barIcons}
|
||||
iconType="MaterialIcons"
|
||||
isClickable
|
||||
text={get(post, 'reblogCount', 0)}
|
||||
textMarginLeft={20}
|
||||
/>
|
||||
<View style={styles.stickyRightWrapper}>
|
||||
|
@ -3,6 +3,7 @@ import searchApi from '../../config/search';
|
||||
import imageApi from '../../config/imageApi';
|
||||
import serverList from '../../config/serverListApi';
|
||||
import { jsonStringify } from '../../utils/jsonUtils';
|
||||
import bugsnag from '../../config/bugsnag';
|
||||
|
||||
export const getCurrencyRate = currency =>
|
||||
api.get(`/currencyRate/${currency.toUpperCase()}/steem`).then(resp => resp.data);
|
||||
@ -313,3 +314,9 @@ export const getSCAccessToken = code =>
|
||||
export const getPromotePosts = () => api.get(`/promoted-posts`).then(resp => resp.data);
|
||||
|
||||
export const purchaseOrder = data => api.post('/purchase-order', data).then(resp => resp.data);
|
||||
|
||||
export const getPostReblogs = data =>
|
||||
api
|
||||
.get(`/post-reblogs/${data.author}/${data.permlink}`)
|
||||
.then(resp => resp.data)
|
||||
.catch(error => bugsnag.notify(error));
|
||||
|
@ -6,14 +6,21 @@ import { postBodySummary, renderPostBody } from '@esteemapp/esteem-render-helper
|
||||
|
||||
// Dsteem
|
||||
import { getActiveVotes } from '../providers/steem/dsteem';
|
||||
import { getPostReblogs } from '../providers/esteem/esteem';
|
||||
|
||||
// Utils
|
||||
import { getReputation } from './reputation';
|
||||
|
||||
export const parsePosts = (posts, currentUserName) =>
|
||||
!posts ? null : posts.map(post => parsePost(post, currentUserName));
|
||||
export const parsePosts = async (posts, currentUserName) => {
|
||||
if (posts) {
|
||||
const promises = posts.map(post => parsePost(post, currentUserName));
|
||||
const formattedPosts = await Promise.all(promises);
|
||||
return formattedPosts;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export const parsePost = (post, currentUserName, isPromoted) => {
|
||||
export const parsePost = async (post, currentUserName, isPromoted) => {
|
||||
if (!post) {
|
||||
return null;
|
||||
}
|
||||
@ -60,6 +67,9 @@ export const parsePost = (post, currentUserName, isPromoted) => {
|
||||
});
|
||||
}
|
||||
|
||||
const postReblogs = await getPostReblogs(post);
|
||||
post.reblogCount = postReblogs.length;
|
||||
|
||||
return post;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user