Merge branch 'comment/delete' of https://github.com/esteemapp/esteem-mobile into comment/delete

This commit is contained in:
u-e 2019-04-07 13:31:28 +03:00
commit 62f44a2524
4 changed files with 30 additions and 1 deletions

View File

@ -44,6 +44,7 @@ class CommentView extends PureComponent {
commentNumber,
currentAccountUsername,
fetchPost,
handleDeleteComment,
handleOnEditPress,
handleOnReplyPress,
handleOnUserPress,
@ -95,6 +96,14 @@ class CommentView extends PureComponent {
iconType="MaterialIcons"
/>
)}
<IconButton
size={18}
iconStyle={styles.leftIcon}
style={styles.leftButton}
name="delete-forever"
onPress={() => handleDeleteComment && handleDeleteComment(comment.author, comment.permlink)}
iconType="MaterialIcons"
/>
</Fragment>
)}
{isShowMoreButton && (

View File

@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { withNavigation } from 'react-navigation';
import { connect } from 'react-redux';
import { getComments } from '../../../providers/steem/dsteem';
import { getComments, deleteComment } from '../../../providers/steem/dsteem';
// Services and Actions
@ -153,6 +153,10 @@ class CommentsContainer extends Component {
},
});
};
_handleDeleteComment = (author, permlink) => {
deleteComment(author, permlink);
}
render() {
const { comments: _comments, selectedPermlink } = this.state;
@ -184,6 +188,7 @@ class CommentsContainer extends Component {
handleOnReplyPress={this._handleOnReplyPress}
isLoggedIn={isLoggedIn}
fetchPost={fetchPost}
handleDeleteComment={this._handleDeleteComment}
{...this.props}
/>
);

View File

@ -38,6 +38,7 @@ class CommentsView extends PureComponent {
isLoggedIn,
isShowSubComments,
marginLeft,
handleDeleteComment,
} = this.props;
return (
@ -50,6 +51,7 @@ class CommentsView extends PureComponent {
comment={item}
commentCount={commentCount || item.children}
commentNumber={commentNumber}
handleDeleteComment={handleDeleteComment}
currentAccountUsername={currentAccountUsername}
fetchPost={fetchPost}
handleOnEditPress={handleOnEditPress}

View File

@ -341,6 +341,19 @@ export const getPurePost = async (author, permlink) => {
}
};
export const deleteComment = (author, permlink) => {
return new Promise((resolve, reject) => {
client.database
.call('comment_delete', [author, permlink])
.then((response) => {
resolve(response);
})
.catch((error) => {
reject(error);
});
});
};
/**
* @method getUser get user data
* @param user post author