mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 12:51:42 +03:00
created delete post option
This commit is contained in:
parent
c447cd78ab
commit
705b848936
@ -57,7 +57,7 @@ class CommentView extends PureComponent {
|
|||||||
voteCount,
|
voteCount,
|
||||||
intl,
|
intl,
|
||||||
author,
|
author,
|
||||||
mainAuthor={mainAuthor}
|
mainAuthor = { mainAuthor },
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isShowSubComments, isPressedShowButton } = this.state;
|
const { isShowSubComments, isPressedShowButton } = this.state;
|
||||||
|
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { withNavigation } from 'react-navigation';
|
import { withNavigation } from 'react-navigation';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { injectIntl } from 'react-intl';
|
||||||
|
|
||||||
// Middleware
|
// Action
|
||||||
|
import { toastNotification } from '../../../redux/actions/uiAction';
|
||||||
|
|
||||||
|
// Dsteem
|
||||||
|
import { deleteComment } from '../../../providers/steem/dsteem';
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import { default as ROUTES } from '../../../constants/routeNames';
|
import { default as ROUTES } from '../../../constants/routeNames';
|
||||||
@ -70,6 +75,23 @@ class PostDisplayContainer extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_handleDeleteComment = (permlink) => {
|
||||||
|
const {
|
||||||
|
currentAccount, pinCode, navigation, dispatch, intl,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
deleteComment(currentAccount, pinCode, permlink).then(() => {
|
||||||
|
navigation.goBack();
|
||||||
|
dispatch(
|
||||||
|
toastNotification(
|
||||||
|
intl.formatMessage({
|
||||||
|
id: 'alert.removed',
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_fetchPost = async () => {
|
_fetchPost = async () => {
|
||||||
const { post, fetchPost } = this.props;
|
const { post, fetchPost } = this.props;
|
||||||
|
|
||||||
@ -84,14 +106,15 @@ class PostDisplayContainer extends Component {
|
|||||||
return (
|
return (
|
||||||
<PostDisplayView
|
<PostDisplayView
|
||||||
author={author}
|
author={author}
|
||||||
isPostUnavailable={isPostUnavailable}
|
|
||||||
currentAccount={currentAccount}
|
currentAccount={currentAccount}
|
||||||
fetchPost={this._fetchPost}
|
fetchPost={this._fetchPost}
|
||||||
handleOnEditPress={this._handleOnEditPress}
|
handleOnEditPress={this._handleOnEditPress}
|
||||||
|
handleOnRemovePress={this._handleDeleteComment}
|
||||||
handleOnReplyPress={this._handleOnReplyPress}
|
handleOnReplyPress={this._handleOnReplyPress}
|
||||||
handleOnVotersPress={this._handleOnVotersPress}
|
handleOnVotersPress={this._handleOnVotersPress}
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
isNewPost={isNewPost}
|
isNewPost={isNewPost}
|
||||||
|
isPostUnavailable={isPostUnavailable}
|
||||||
parentPost={parentPost}
|
parentPost={parentPost}
|
||||||
post={post}
|
post={post}
|
||||||
/>
|
/>
|
||||||
@ -101,8 +124,8 @@ class PostDisplayContainer extends Component {
|
|||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
currentAccount: state.account.currentAccount,
|
currentAccount: state.account.currentAccount,
|
||||||
|
pinCode: state.account.pin,
|
||||||
isLoggedIn: state.application.isLoggedIn,
|
isLoggedIn: state.application.isLoggedIn,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default withNavigation(connect(mapStateToProps)(PostDisplayContainer));
|
export default withNavigation(connect(mapStateToProps)(injectIntl(PostDisplayContainer)));
|
||||||
|
@ -3,6 +3,8 @@ import {
|
|||||||
View, Text, ScrollView, Dimensions,
|
View, Text, ScrollView, Dimensions,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { injectIntl } from 'react-intl';
|
import { injectIntl } from 'react-intl';
|
||||||
|
import get from 'lodash/get';
|
||||||
|
import ActionSheet from 'react-native-actionsheet';
|
||||||
|
|
||||||
// Providers
|
// Providers
|
||||||
import { userActivity } from '../../../providers/esteem/ePoint';
|
import { userActivity } from '../../../providers/esteem/ePoint';
|
||||||
@ -44,7 +46,7 @@ class PostDisplayView extends PureComponent {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { currentAccount, isLoggedIn, isNewPost } = this.props;
|
const { currentAccount, isLoggedIn, isNewPost } = this.props;
|
||||||
|
|
||||||
if (isLoggedIn && currentAccount && currentAccount.name && !isNewPost) {
|
if (isLoggedIn && get(currentAccount, 'name') && !isNewPost) {
|
||||||
userActivity(currentAccount.name, 10);
|
userActivity(currentAccount.name, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,8 +88,8 @@ class PostDisplayView extends PureComponent {
|
|||||||
iconStyle={styles.barIcons}
|
iconStyle={styles.barIcons}
|
||||||
iconType="MaterialIcons"
|
iconType="MaterialIcons"
|
||||||
isClickable
|
isClickable
|
||||||
onPress={() => handleOnVotersPress && handleOnVotersPress(post.active_votes)}
|
onPress={() => handleOnVotersPress && handleOnVotersPress(get(post, 'active_votes'))}
|
||||||
text={post && post.vote_count}
|
text={get(post, 'vote_count')}
|
||||||
textMarginLeft={20}
|
textMarginLeft={20}
|
||||||
/>
|
/>
|
||||||
<TextWithIcon
|
<TextWithIcon
|
||||||
@ -95,18 +97,29 @@ class PostDisplayView extends PureComponent {
|
|||||||
iconStyle={styles.barIcons}
|
iconStyle={styles.barIcons}
|
||||||
iconType="MaterialIcons"
|
iconType="MaterialIcons"
|
||||||
isClickable
|
isClickable
|
||||||
text={post && post.children}
|
text={get(post, 'children')}
|
||||||
textMarginLeft={20}
|
textMarginLeft={20}
|
||||||
/>
|
/>
|
||||||
<View style={styles.stickyRightWrapper}>
|
<View style={styles.stickyRightWrapper}>
|
||||||
{post && currentAccount && currentAccount.name === post.author && (
|
{get(currentAccount, 'name') === get(post, 'author') && (
|
||||||
<IconButton
|
<Fragment>
|
||||||
iconStyle={styles.barIconRight}
|
{!get(post, 'children') && !get(post, 'vote_count') && (
|
||||||
iconType="MaterialIcons"
|
<IconButton
|
||||||
name="create"
|
iconStyle={styles.barIconRight}
|
||||||
onPress={() => handleOnEditPress && handleOnEditPress()}
|
iconType="MaterialIcons"
|
||||||
style={styles.barIconButton}
|
name="delete-forever"
|
||||||
/>
|
onPress={() => this.ActionSheet.show()}
|
||||||
|
style={styles.barIconButton}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<IconButton
|
||||||
|
iconStyle={styles.barIconRight}
|
||||||
|
iconType="MaterialIcons"
|
||||||
|
name="create"
|
||||||
|
onPress={() => handleOnEditPress && handleOnEditPress()}
|
||||||
|
style={styles.barIconButton}
|
||||||
|
/>
|
||||||
|
</Fragment>
|
||||||
)}
|
)}
|
||||||
{isLoggedIn && (
|
{isLoggedIn && (
|
||||||
<IconButton
|
<IconButton
|
||||||
@ -132,6 +145,7 @@ class PostDisplayView extends PureComponent {
|
|||||||
isPostUnavailable,
|
isPostUnavailable,
|
||||||
author,
|
author,
|
||||||
intl,
|
intl,
|
||||||
|
handleOnRemovePress,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { postHeight, scrollHeight, isLoadedComments } = this.state;
|
const { postHeight, scrollHeight, isLoadedComments } = this.state;
|
||||||
|
|
||||||
@ -197,6 +211,13 @@ class PostDisplayView extends PureComponent {
|
|||||||
)}
|
)}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
{post && this._getTabBar(true)}
|
{post && this._getTabBar(true)}
|
||||||
|
<ActionSheet
|
||||||
|
ref={o => (this.ActionSheet = o)}
|
||||||
|
options={[intl.formatMessage({ id: 'alert.delete' }), intl.formatMessage({ id: 'alert.cancel' })]}
|
||||||
|
title={intl.formatMessage({ id: 'post.remove_alert' })}
|
||||||
|
cancelButtonIndex={1}
|
||||||
|
onPress={index => (index === 0 ? handleOnRemovePress(get(post, 'permlink')) : null)}
|
||||||
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,8 @@
|
|||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
"copied": "Copied!",
|
"copied": "Copied!",
|
||||||
"no_internet": "No connection!",
|
"no_internet": "No connection!",
|
||||||
"confirm": "Confirm"
|
"confirm": "Confirm",
|
||||||
|
"removed": "Removed"
|
||||||
},
|
},
|
||||||
"post": {
|
"post": {
|
||||||
"reblog_alert": "Are you sure you want to reblog?",
|
"reblog_alert": "Are you sure you want to reblog?",
|
||||||
|
Loading…
Reference in New Issue
Block a user