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 { withNavigation } from 'react-navigation';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
// Dsteem
|
// Services
|
||||||
import { getPost } from '../../../providers/steem/dsteem';
|
import { getPost } from '../../../providers/steem/dsteem';
|
||||||
|
|
||||||
import PostCardView from '../view/postCardView';
|
import PostCardView from '../view/postCardView';
|
||||||
|
@ -15,12 +15,7 @@ export default EStyleSheet.create({
|
|||||||
padding: 0,
|
padding: 0,
|
||||||
margin: 0,
|
margin: 0,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
alignSelf: 'flex-end',
|
||||||
comment: {
|
|
||||||
alignSelf: 'center',
|
|
||||||
fontSize: 10,
|
|
||||||
marginLeft: 3,
|
|
||||||
color: '$iconColor',
|
|
||||||
},
|
},
|
||||||
commentIcon: {
|
commentIcon: {
|
||||||
alignSelf: 'flex-start',
|
alignSelf: 'flex-start',
|
||||||
@ -28,6 +23,7 @@ export default EStyleSheet.create({
|
|||||||
color: '$iconColor',
|
color: '$iconColor',
|
||||||
margin: 0,
|
margin: 0,
|
||||||
width: 20,
|
width: 20,
|
||||||
|
marginLeft: 25,
|
||||||
},
|
},
|
||||||
postBodyWrapper: {
|
postBodyWrapper: {
|
||||||
marginHorizontal: 9,
|
marginHorizontal: 9,
|
||||||
@ -60,7 +56,6 @@ export default EStyleSheet.create({
|
|||||||
backgroundColor: '$primaryBackgroundColor',
|
backgroundColor: '$primaryBackgroundColor',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
margin: 16,
|
margin: 16,
|
||||||
justifyContent: 'space-between',
|
|
||||||
},
|
},
|
||||||
bodyHeader: {
|
bodyHeader: {
|
||||||
backgroundColor: '$primaryBackgroundColor',
|
backgroundColor: '$primaryBackgroundColor',
|
||||||
@ -70,7 +65,14 @@ export default EStyleSheet.create({
|
|||||||
marginBottom: 12,
|
marginBottom: 12,
|
||||||
},
|
},
|
||||||
leftFooterWrapper: {
|
leftFooterWrapper: {
|
||||||
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'flex-start',
|
||||||
|
},
|
||||||
|
rightFooterWrapper: {
|
||||||
|
flex: 1,
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'flex-end',
|
||||||
},
|
},
|
||||||
dropdownWrapper: {
|
dropdownWrapper: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
@ -10,7 +10,6 @@ import { getTimeFromNow } from '../../../utils/time';
|
|||||||
// Components
|
// Components
|
||||||
import { PostHeaderDescription } from '../../postElements';
|
import { PostHeaderDescription } from '../../postElements';
|
||||||
import { PostDropdown } from '../../postDropdown';
|
import { PostDropdown } from '../../postDropdown';
|
||||||
import { Icon } from '../../icon';
|
|
||||||
import { TextWithIcon } from '../../basicUIElements';
|
import { TextWithIcon } from '../../basicUIElements';
|
||||||
|
|
||||||
// STEEM
|
// STEEM
|
||||||
@ -130,17 +129,30 @@ class PostCardView extends Component {
|
|||||||
<View style={styles.leftFooterWrapper}>
|
<View style={styles.leftFooterWrapper}>
|
||||||
<Upvote fetchPost={fetchPost} isShowPayoutValue content={content} />
|
<Upvote fetchPost={fetchPost} isShowPayoutValue content={content} />
|
||||||
<TouchableOpacity style={styles.commentButton} onPress={this._handleOnVotersPress}>
|
<TouchableOpacity style={styles.commentButton} onPress={this._handleOnVotersPress}>
|
||||||
<Icon
|
<TextWithIcon
|
||||||
style={[styles.commentIcon, { marginLeft: 25 }]}
|
iconName="people"
|
||||||
|
iconStyle={styles.commentIcon}
|
||||||
iconType="MaterialIcons"
|
iconType="MaterialIcons"
|
||||||
name="people"
|
isClickable
|
||||||
|
text={get(content, 'vote_count', 0)}
|
||||||
/>
|
/>
|
||||||
<Text style={styles.comment}>{get(content, 'vote_count', 0)}</Text>
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.commentButton}>
|
<View style={styles.rightFooterWrapper}>
|
||||||
<Icon style={[styles.commentIcon]} iconType="MaterialIcons" name="comment" />
|
<TextWithIcon
|
||||||
<Text style={styles.comment}>{get(content, 'children')}</Text>
|
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>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -85,7 +85,7 @@ class PostDisplayView extends PureComponent {
|
|||||||
iconType="MaterialIcons"
|
iconType="MaterialIcons"
|
||||||
isClickable
|
isClickable
|
||||||
onPress={() => handleOnVotersPress && handleOnVotersPress(get(post, 'active_votes'))}
|
onPress={() => handleOnVotersPress && handleOnVotersPress(get(post, 'active_votes'))}
|
||||||
text={get(post, 'vote_count')}
|
text={get(post, 'vote_count', 0)}
|
||||||
textMarginLeft={20}
|
textMarginLeft={20}
|
||||||
/>
|
/>
|
||||||
<TextWithIcon
|
<TextWithIcon
|
||||||
@ -93,7 +93,15 @@ class PostDisplayView extends PureComponent {
|
|||||||
iconStyle={styles.barIcons}
|
iconStyle={styles.barIcons}
|
||||||
iconType="MaterialIcons"
|
iconType="MaterialIcons"
|
||||||
isClickable
|
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}
|
textMarginLeft={20}
|
||||||
/>
|
/>
|
||||||
<View style={styles.stickyRightWrapper}>
|
<View style={styles.stickyRightWrapper}>
|
||||||
|
@ -3,6 +3,7 @@ import searchApi from '../../config/search';
|
|||||||
import imageApi from '../../config/imageApi';
|
import imageApi from '../../config/imageApi';
|
||||||
import serverList from '../../config/serverListApi';
|
import serverList from '../../config/serverListApi';
|
||||||
import { jsonStringify } from '../../utils/jsonUtils';
|
import { jsonStringify } from '../../utils/jsonUtils';
|
||||||
|
import bugsnag from '../../config/bugsnag';
|
||||||
|
|
||||||
export const getCurrencyRate = currency =>
|
export const getCurrencyRate = currency =>
|
||||||
api.get(`/currencyRate/${currency.toUpperCase()}/steem`).then(resp => resp.data);
|
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 getPromotePosts = () => api.get(`/promoted-posts`).then(resp => resp.data);
|
||||||
|
|
||||||
export const purchaseOrder = data => api.post('/purchase-order', data).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
|
// Dsteem
|
||||||
import { getActiveVotes } from '../providers/steem/dsteem';
|
import { getActiveVotes } from '../providers/steem/dsteem';
|
||||||
|
import { getPostReblogs } from '../providers/esteem/esteem';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { getReputation } from './reputation';
|
import { getReputation } from './reputation';
|
||||||
|
|
||||||
export const parsePosts = (posts, currentUserName) =>
|
export const parsePosts = async (posts, currentUserName) => {
|
||||||
!posts ? null : posts.map(post => parsePost(post, 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) {
|
if (!post) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -60,6 +67,9 @@ export const parsePost = (post, currentUserName, isPromoted) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const postReblogs = await getPostReblogs(post);
|
||||||
|
post.reblogCount = postReblogs.length;
|
||||||
|
|
||||||
return post;
|
return post;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user