Close Thread view when the root post has been deleted (#1114)

This commit is contained in:
enahum 2017-11-09 11:22:48 -03:00 committed by Harrison Healey
parent 58efa5863b
commit 2a6b49cdfa
2 changed files with 9 additions and 1 deletions

View file

@ -133,7 +133,7 @@ class Post extends PureComponent {
handlePostDelete = () => {
const {formatMessage} = this.props.intl;
const {post, actions} = this.props;
const {actions, currentUserId, post} = this.props;
Alert.alert(
formatMessage({id: 'mobile.post.delete_title', defaultMessage: 'Delete Post'}),
@ -147,6 +147,9 @@ class Post extends PureComponent {
onPress: () => {
this.editDisableAction.cancel();
actions.deletePost(post);
if (post.user_id === currentUserId) {
actions.removePost(post);
}
}
}]
);

View file

@ -47,6 +47,11 @@ class Thread extends PureComponent {
}
componentWillReceiveProps(nextProps) {
if (this.props.postIds !== nextProps.postIds && !nextProps.postIds.length) {
this.props.navigator.pop();
return;
}
if (!this.state.lastViewedAt) {
this.setState({lastViewedAt: nextProps.myMember.last_viewed_at});
}