Fixed comment filter issue

This commit is contained in:
Mustafa Buyukcelebi 2019-08-12 14:29:00 +03:00
parent 536c7424b3
commit bb4dd26a2e

View File

@ -51,9 +51,11 @@ class CommentsContainer extends Component {
// Component Functions // Component Functions
_shortComments = sortOrder => { _shortComments = (sortOrder, comments) => {
const { comments: parent } = this.state; const { comments: parent } = this.state;
const sortedComments = comments || parent;
const allPayout = c => const allPayout = c =>
parseFloat(get(c, 'pending_payout_value').split(' ')[0]) + parseFloat(get(c, 'pending_payout_value').split(' ')[0]) +
parseFloat(get(c, 'total_payout_value').split(' ')[0]) + parseFloat(get(c, 'total_payout_value').split(' ')[0]) +
@ -116,23 +118,31 @@ class CommentsContainer extends Component {
}, },
}; };
parent.sort(sortOrders[sortOrder]); sortedComments.sort(sortOrders[sortOrder]);
return parent; return sortedComments;
}; };
_getComments = async () => { _getComments = async () => {
const { const {
author, author,
permlink, permlink,
selectedFilter,
currentAccount: { name }, currentAccount: { name },
} = this.props; } = this.props;
await getComments(author, permlink, name) await getComments(author, permlink, name)
.then(comments => { .then(comments => {
if (selectedFilter && selectedFilter !== 'TRENDING') {
const sortComments = this._shortComments(selectedFilter, comments);
this.setState({
comments: sortComments,
});
} else {
this.setState({ this.setState({
comments, comments,
}); });
}
}) })
.catch(() => {}); .catch(() => {});
}; };