mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 12:21:31 +03:00
wip on comment is vote
This commit is contained in:
parent
cb9268c2d0
commit
11b79943b6
@ -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,
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user