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
_shortComments = sortOrder => {
_shortComments = (sortOrder, comments) => {
const { comments: parent } = this.state;
const sortedComments = comments || parent;
const allPayout = c =>
parseFloat(get(c, 'pending_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 () => {
const {
author,
permlink,
selectedFilter,
currentAccount: { name },
} = this.props;
await getComments(author, permlink, name)
.then(comments => {
if (selectedFilter && selectedFilter !== 'TRENDING') {
const sortComments = this._shortComments(selectedFilter, comments);
this.setState({
comments: sortComments,
});
} else {
this.setState({
comments,
});
}
})
.catch(() => {});
};