From 70b4b3f44998673f4588ef364fe9f130af4de6db Mon Sep 17 00:00:00 2001 From: feruz Date: Mon, 13 Jan 2020 13:27:46 +0200 Subject: [PATCH] fix comments merge --- src/containers/profileContainer.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/containers/profileContainer.js b/src/containers/profileContainer.js index af8a27453..c14cb0bb0 100644 --- a/src/containers/profileContainer.js +++ b/src/containers/profileContainer.js @@ -23,6 +23,7 @@ import { getIsFavorite, addFavorite, removeFavorite } from '../providers/esteem/ // Utilitites import { getRcPower, getVotingPower } from '../utils/manaBar'; +import { unionWith } from '../utils/postParser'; // Constants import { default as ROUTES } from '../constants/routeNames'; @@ -77,7 +78,7 @@ class ProfileContainer extends Component { } _getReplies = async query => { - const { isOwnProfile } = this.state; + const { isOwnProfile, comments } = this.state; let repliesAction; if (!isOwnProfile) { @@ -85,16 +86,18 @@ class ProfileContainer extends Component { } else { repliesAction = getRepliesByLastUpdate; } - - await repliesAction({ - start_author: query.author, - start_permlink: query.permlink, - limit: 10, - }).then(result => { - this.setState({ - comments: result, + if (query) { + await repliesAction({ + start_author: query.author, + start_permlink: query.permlink, + limit: 10, + }).then(result => { + let _comments = unionWith(comments, result, 'permlink'); + this.setState({ + comments: _comments, + }); }); - }); + } }; _handleFollowUnfollowUser = async isFollowAction => {