wip on comment is vote

This commit is contained in:
u-e 2019-06-12 00:38:15 +03:00
parent cb9268c2d0
commit 11b79943b6
3 changed files with 16 additions and 6 deletions

View File

@ -123,9 +123,13 @@ class CommentsContainer extends Component {
};
_getComments = () => {
const { author, permlink } = this.props;
const {
author,
permlink,
currentAccount: { name },
} = this.props;
getComments(author, permlink).then(comments => {
getComments(author, permlink, name).then(comments => {
this.setState({
comments,
});

View File

@ -398,16 +398,16 @@ export const deleteComment = (currentAccount, pin, permlink) => {
* @param user post author
* @param permlink post permlink
*/
export const getComments = (user, permlink) => {
export const getComments = (user, permlink, currentUserName) => {
let comments;
return new Promise((resolve, reject) => {
client.database
.call('get_content_replies', [user, permlink])
.then(result => {
comments = parseComments(result);
comments = parseComments(result, currentUserName);
})
.then(() => {
resolve(comments);
resolve(parseComments(comments, currentUserName));
})
.catch(error => {
reject(error);

View File

@ -98,7 +98,7 @@ const postImage = (metaData, body) => {
return '';
};
export const parseComments = comments => {
export const parseComments = (comments, currentUserName) => {
forEach(comments, comment => {
comment.pending_payout_value = parseFloat(comment.pending_payout_value).toFixed(3);
comment.vote_count = comment.active_votes.length;
@ -107,6 +107,12 @@ export const parseComments = comments => {
comment.markdownBody = comment.body;
comment.body = renderPostBody(comment);
comment.summary = `"${postBodySummary(comment, 100, true)}"`;
if (currentUserName) {
comment.is_voted = isVoted(comment.active_votes, currentUserName);
} else {
comment.is_voted = false;
}
});
return comments;
};