mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 22:03:21 +03:00
Fixed reply delete issue
This commit is contained in:
parent
8ab1989e5c
commit
9ab3529acd
@ -129,8 +129,13 @@ class CommentsContainer extends Component {
|
|||||||
permlink,
|
permlink,
|
||||||
selectedFilter,
|
selectedFilter,
|
||||||
currentAccount: { name },
|
currentAccount: { name },
|
||||||
|
isOwnProfile,
|
||||||
|
fetchPost,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
if (isOwnProfile) {
|
||||||
|
fetchPost();
|
||||||
|
} else {
|
||||||
await getComments(author, permlink, name)
|
await getComments(author, permlink, name)
|
||||||
.then(comments => {
|
.then(comments => {
|
||||||
if (selectedFilter && selectedFilter !== 'TRENDING') {
|
if (selectedFilter && selectedFilter !== 'TRENDING') {
|
||||||
@ -145,6 +150,7 @@ class CommentsContainer extends Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleOnReplyPress = item => {
|
_handleOnReplyPress = item => {
|
||||||
@ -175,10 +181,17 @@ class CommentsContainer extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_handleDeleteComment = permlink => {
|
_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(() => {
|
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}
|
isShowMoreButton={isShowMoreButton}
|
||||||
commentNumber={commentNumber || 1}
|
commentNumber={commentNumber || 1}
|
||||||
commentCount={commentCount}
|
commentCount={commentCount}
|
||||||
comments={_comments || comments}
|
comments={_comments.length > 0 ? _comments : comments}
|
||||||
currentAccountUsername={currentAccount.name}
|
currentAccountUsername={currentAccount.name}
|
||||||
handleOnEditPress={this._handleOnEditPress}
|
handleOnEditPress={this._handleOnEditPress}
|
||||||
handleOnReplyPress={this._handleOnReplyPress}
|
handleOnReplyPress={this._handleOnReplyPress}
|
||||||
@ -248,7 +261,6 @@ class CommentsContainer extends Component {
|
|||||||
fetchPost={fetchPost}
|
fetchPost={fetchPost}
|
||||||
handleDeleteComment={this._handleDeleteComment}
|
handleDeleteComment={this._handleDeleteComment}
|
||||||
handleOnPressCommentMenu={this._handleOnPressCommentMenu}
|
handleOnPressCommentMenu={this._handleOnPressCommentMenu}
|
||||||
{...this.props}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { PureComponent, Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
import { FlatList } from 'react-native';
|
import { FlatList } from 'react-native';
|
||||||
import ActionSheet from 'react-native-actionsheet';
|
import ActionSheet from 'react-native-actionsheet';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
@ -11,7 +11,7 @@ import { Comment } from '../../comment';
|
|||||||
// Styles
|
// Styles
|
||||||
import styles from './commentStyles';
|
import styles from './commentStyles';
|
||||||
|
|
||||||
class CommentsView extends PureComponent {
|
class CommentsView extends Component {
|
||||||
/* Props
|
/* Props
|
||||||
* ------------------------------------------------
|
* ------------------------------------------------
|
||||||
* @prop { type } name - Description....
|
* @prop { type } name - Description....
|
||||||
|
@ -373,7 +373,7 @@ export const deleteComment = (currentAccount, pin, permlink) => {
|
|||||||
const key = getAnyPrivateKey(currentAccount.local, digitPinCode);
|
const key = getAnyPrivateKey(currentAccount.local, digitPinCode);
|
||||||
|
|
||||||
if (currentAccount.local.authType === AUTH_TYPE.STEEM_CONNECT) {
|
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({
|
const api = steemConnect.Initialize({
|
||||||
accessToken: token,
|
accessToken: token,
|
||||||
});
|
});
|
||||||
|
@ -226,7 +226,12 @@ class ProfileScreen extends PureComponent {
|
|||||||
>
|
>
|
||||||
{comments && comments.length > 0 ? (
|
{comments && comments.length > 0 ? (
|
||||||
<ScrollView onScroll={this._handleOnScroll}>
|
<ScrollView onScroll={this._handleOnScroll}>
|
||||||
<Comments isProfilePreview comments={comments} fetchPost={getReplies} />
|
<Comments
|
||||||
|
isProfilePreview
|
||||||
|
comments={comments}
|
||||||
|
fetchPost={getReplies}
|
||||||
|
isOwnProfile={!isReverseHeader}
|
||||||
|
/>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
) : (
|
) : (
|
||||||
<NoPost
|
<NoPost
|
||||||
|
Loading…
Reference in New Issue
Block a user