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

View File

@ -1,6 +1,5 @@
import React, { PureComponent, Fragment } from 'react'; import React, { PureComponent, Fragment } from 'react';
import { View, FlatList } from 'react-native'; import { View, FlatList } from 'react-native';
import { injectIntl } from 'react-intl';
import { getTimeFromNow } from '../../../utils/time'; import { getTimeFromNow } from '../../../utils/time';
// Constants // Constants
@ -45,7 +44,6 @@ class CommentsView extends PureComponent {
isProfilePreview, isProfilePreview,
marginLeft, marginLeft,
fetchPost, fetchPost,
intl,
} = this.props; } = this.props;
return ( 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) { if (navigationParams.post) {
post = navigationParams.post; ({ post } = navigationParams);
this.setState({ post }); this.setState({ post });
} }
if (navigationParams.isReply) { if (navigationParams.isReply) {
isReply = navigationParams.isReply; ({ isReply } = navigationParams);
this.setState({ isReply }); this.setState({ isReply });
} }
if (navigationParams.isEdit) { if (navigationParams.isEdit) {
isEdit = navigationParams.isEdit; ({ isEdit } = navigationParams);
this.setState( this.setState(
{ {
isEdit, isEdit,
@ -117,7 +117,7 @@ class EditorContainer extends Component {
draftPost: { body: result.body, title: result.title, tags: result.tags.split(',') }, draftPost: { body: result.body, title: result.title, tags: result.tags.split(',') },
}); });
}) })
.catch((error) => { .catch(() => {
// alert(error); // alert(error);
}); });
}; };
@ -308,7 +308,7 @@ class EditorContainer extends Component {
options, options,
0, 0,
) )
.then((result) => { .then(() => {
Alert.alert( Alert.alert(
intl.formatMessage({ intl.formatMessage({
id: 'alert.success', id: 'alert.success',
@ -361,7 +361,7 @@ class EditorContainer extends Component {
options, options,
0, 0,
) )
.then((result) => { .then(() => {
this._handleSubmitSuccess(); this._handleSubmitSuccess();
}) })
.catch((error) => { .catch((error) => {
@ -403,7 +403,7 @@ class EditorContainer extends Component {
newBody, newBody,
jsonMeta, jsonMeta,
) )
.then((result) => { .then(() => {
this._handleSubmitSuccess(); this._handleSubmitSuccess();
}) })
.catch((error) => { .catch((error) => {