Fixed crash issue when user try to reply his replies

This commit is contained in:
Mustafa Buyukcelebi 2019-01-16 11:41:54 +03:00
parent d7c685f17a
commit 08d672cf5c
3 changed files with 17 additions and 18 deletions

View File

@ -55,14 +55,14 @@ class CommentsContainer extends Component {
};
_handleOnReplyPress = (item) => {
const { navigation, fetchPost } = this.props;
const { navigation } = this.props;
navigation.navigate({
routeName: ROUTES.SCREENS.EDITOR,
params: {
isReply: true,
post: item,
fetchPost,
fetchPost: this._getComments,
},
});
};
@ -82,22 +82,23 @@ class CommentsContainer extends Component {
};
render() {
const { comments } = this.state;
const { comments: _comments } = this.state;
const {
isLoggedIn, commentCount, author, permlink, currentAccount, fetchPost,
isLoggedIn, commentCount, author, permlink, currentAccount, isProfilePreview, comments,
} = this.props;
return (
<CommentsView
author={author}
commentCount={commentCount}
comments={comments}
commentNumber={commentCount}
comments={comments || _comments}
currentAccountUsername={currentAccount.name}
handleOnEditPress={this._handleOnEditPress}
handleOnReplyPress={this._handleOnReplyPress}
isLoggedIn={isLoggedIn}
permlink={permlink}
fetchPost={fetchPost}
{...this.props}
fetchPost={this._getComments}
isProfilePreview={isProfilePreview}
/>
);
}

View File

@ -1,6 +1,5 @@
import React, { PureComponent, Fragment } from 'react';
import { View, FlatList } from 'react-native';
import { injectIntl } from 'react-intl';
import { getTimeFromNow } from '../../../utils/time';
// Constants
@ -45,7 +44,6 @@ class CommentsView extends PureComponent {
isProfilePreview,
marginLeft,
fetchPost,
intl,
} = this.props;
return (
@ -122,4 +120,4 @@ class CommentsView extends PureComponent {
}
}
export default injectIntl(CommentsView);
export default CommentsView;

View File

@ -76,17 +76,17 @@ class EditorContainer extends Component {
}
if (navigationParams.post) {
post = navigationParams.post;
({ post } = navigationParams);
this.setState({ post });
}
if (navigationParams.isReply) {
isReply = navigationParams.isReply;
({ isReply } = navigationParams);
this.setState({ isReply });
}
if (navigationParams.isEdit) {
isEdit = navigationParams.isEdit;
({ isEdit } = navigationParams);
this.setState(
{
isEdit,
@ -117,7 +117,7 @@ class EditorContainer extends Component {
draftPost: { body: result.body, title: result.title, tags: result.tags.split(',') },
});
})
.catch((error) => {
.catch(() => {
// alert(error);
});
};
@ -308,7 +308,7 @@ class EditorContainer extends Component {
options,
0,
)
.then((result) => {
.then(() => {
Alert.alert(
intl.formatMessage({
id: 'alert.success',
@ -361,7 +361,7 @@ class EditorContainer extends Component {
options,
0,
)
.then((result) => {
.then(() => {
this._handleSubmitSuccess();
})
.catch((error) => {
@ -403,7 +403,7 @@ class EditorContainer extends Component {
newBody,
jsonMeta,
)
.then((result) => {
.then(() => {
this._handleSubmitSuccess();
})
.catch((error) => {