diff --git a/src/components/comments/container/commentsContainer.js b/src/components/comments/container/commentsContainer.js index 3d8565c8f..94cff2475 100644 --- a/src/components/comments/container/commentsContainer.js +++ b/src/components/comments/container/commentsContainer.js @@ -129,22 +129,28 @@ class CommentsContainer extends Component { permlink, selectedFilter, currentAccount: { name }, + isOwnProfile, + fetchPost, } = 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(() => {}); + if (isOwnProfile) { + fetchPost(); + } else { + 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(() => {}); + } }; _handleOnReplyPress = item => { @@ -175,10 +181,17 @@ class CommentsContainer extends Component { }; _handleDeleteComment = permlink => { - const { currentAccount, pinCode } = this.props; + const { currentAccount, pinCode, comments } = this.props; + const { comments: _comments } = this.state; + let filteredComments; deleteComment(currentAccount, pinCode, permlink).then(() => { - this._getComments(); + if (_comments.length > 0) { + filteredComments = _comments.filter(item => item.permlink !== permlink); + } else { + filteredComments = comments.filter(item => item.permlink !== permlink); + } + this.setState({ comments: filteredComments }); }); }; @@ -240,7 +253,7 @@ class CommentsContainer extends Component { isShowMoreButton={isShowMoreButton} commentNumber={commentNumber || 1} commentCount={commentCount} - comments={_comments || comments} + comments={_comments.length > 0 ? _comments : comments} currentAccountUsername={currentAccount.name} handleOnEditPress={this._handleOnEditPress} handleOnReplyPress={this._handleOnReplyPress} @@ -248,7 +261,6 @@ class CommentsContainer extends Component { fetchPost={fetchPost} handleDeleteComment={this._handleDeleteComment} handleOnPressCommentMenu={this._handleOnPressCommentMenu} - {...this.props} /> ); } diff --git a/src/components/comments/view/commentsView.js b/src/components/comments/view/commentsView.js index 197947ca5..29e7b60ac 100644 --- a/src/components/comments/view/commentsView.js +++ b/src/components/comments/view/commentsView.js @@ -1,4 +1,4 @@ -import React, { PureComponent, Fragment } from 'react'; +import React, { Component, Fragment } from 'react'; import { FlatList } from 'react-native'; import ActionSheet from 'react-native-actionsheet'; import get from 'lodash/get'; @@ -11,7 +11,7 @@ import { Comment } from '../../comment'; // Styles import styles from './commentStyles'; -class CommentsView extends PureComponent { +class CommentsView extends Component { /* Props * ------------------------------------------------ * @prop { type } name - Description.... diff --git a/src/providers/steem/dsteem.js b/src/providers/steem/dsteem.js index 21ed0fce2..77883275f 100644 --- a/src/providers/steem/dsteem.js +++ b/src/providers/steem/dsteem.js @@ -373,7 +373,7 @@ export const deleteComment = (currentAccount, pin, permlink) => { const key = getAnyPrivateKey(currentAccount.local, digitPinCode); if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) { - const token = decryptKey(currentAccount.accessToken, pin); + const token = decryptKey(currentAccount.local.accessToken, digitPinCode); const api = steemConnect.Initialize({ accessToken: token, }); diff --git a/src/screens/profile/screen/profileScreen.js b/src/screens/profile/screen/profileScreen.js index 6641f240e..edc7740d4 100644 --- a/src/screens/profile/screen/profileScreen.js +++ b/src/screens/profile/screen/profileScreen.js @@ -226,7 +226,12 @@ class ProfileScreen extends PureComponent { > {comments && comments.length > 0 ? ( - + ) : (