diff --git a/src/components/postCard/container/postCardContainer.js b/src/components/postCard/container/postCardContainer.js index 5b725d2a9..7550f745f 100644 --- a/src/components/postCard/container/postCardContainer.js +++ b/src/components/postCard/container/postCardContainer.js @@ -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'; diff --git a/src/components/postCard/view/postCardStyles.js b/src/components/postCard/view/postCardStyles.js index e8c5715d0..88716065b 100644 --- a/src/components/postCard/view/postCardStyles.js +++ b/src/components/postCard/view/postCardStyles.js @@ -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', diff --git a/src/components/postCard/view/postCardView.js b/src/components/postCard/view/postCardView.js index e43eb30d9..0ffc7362e 100644 --- a/src/components/postCard/view/postCardView.js +++ b/src/components/postCard/view/postCardView.js @@ -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 { - - {get(content, 'vote_count', 0)} - - - {get(content, 'children')} + + + diff --git a/src/components/postView/view/postDisplayView.js b/src/components/postView/view/postDisplayView.js index c12ed2089..8263106e2 100644 --- a/src/components/postView/view/postDisplayView.js +++ b/src/components/postView/view/postDisplayView.js @@ -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} /> + diff --git a/src/providers/esteem/esteem.js b/src/providers/esteem/esteem.js index b20843e73..aee8c4820 100644 --- a/src/providers/esteem/esteem.js +++ b/src/providers/esteem/esteem.js @@ -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)); diff --git a/src/utils/postParser.js b/src/utils/postParser.js index 75518b274..03f9b5e49 100644 --- a/src/utils/postParser.js +++ b/src/utils/postParser.js @@ -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; };