Now handles commenting on a deleted post gracefully, and checks for any areas where data may no longer exist once a post has been deleted
Этот коммит содержится в:
@@ -106,10 +106,11 @@ export default class CreateComment extends React.Component {
|
|||||||
let state = {};
|
let state = {};
|
||||||
|
|
||||||
if (err.message === 'Invalid RootId parameter') {
|
if (err.message === 'Invalid RootId parameter') {
|
||||||
|
PostStore.removePendingPost(post.channel_id, post.pending_post_id);
|
||||||
|
|
||||||
if ($('#post_deleted').length > 0) {
|
if ($('#post_deleted').length > 0) {
|
||||||
$('#post_deleted').modal('show');
|
$('#post_deleted').modal('show');
|
||||||
}
|
}
|
||||||
PostStore.removePendingPost(post.pending_post_id);
|
|
||||||
} else {
|
} else {
|
||||||
post.state = Constants.POST_FAILED;
|
post.state = Constants.POST_FAILED;
|
||||||
PostStore.updatePendingPost(post);
|
PostStore.updatePendingPost(post);
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ export default class PostDeletedModal extends React.Component {
|
|||||||
|
|
||||||
this.state = {};
|
this.state = {};
|
||||||
}
|
}
|
||||||
handleClose(e) {
|
componentDidMount() {
|
||||||
e.preventDefault();
|
$(React.findDOMNode(this.refs.modal)).on('hidden.bs.modal', () => {
|
||||||
|
this.handleClose();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
handleClose() {
|
||||||
AppDispatcher.handleServerAction({
|
AppDispatcher.handleServerAction({
|
||||||
type: ActionTypes.RECIEVED_SEARCH,
|
type: ActionTypes.RECIEVED_SEARCH,
|
||||||
results: null
|
results: null
|
||||||
@@ -56,26 +59,25 @@ export default class PostDeletedModal extends React.Component {
|
|||||||
data-dismiss='modal'
|
data-dismiss='modal'
|
||||||
aria-label='Close'
|
aria-label='Close'
|
||||||
>
|
>
|
||||||
<span aria-hidden='true'>×</span>
|
<span aria-hidden='true'>{'×'}</span>
|
||||||
</button>
|
</button>
|
||||||
<h4
|
<h4
|
||||||
className='modal-title'
|
className='modal-title'
|
||||||
id='myModalLabel'
|
id='myModalLabel'
|
||||||
>
|
>
|
||||||
Post deleted
|
{'Comment could not be posted'}
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div className='modal-body'>
|
<div className='modal-body'>
|
||||||
<p>The post you were viewing was deleted by the owner.</p>
|
<p>{'Someone deleted the message on which you tried to post a comment.'}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className='modal-footer'>
|
<div className='modal-footer'>
|
||||||
<button
|
<button
|
||||||
type='button'
|
type='button'
|
||||||
className='btn btn-primary'
|
className='btn btn-primary'
|
||||||
data-dismiss='modal'
|
data-dismiss='modal'
|
||||||
onClick={this.handleClose}
|
|
||||||
>
|
>
|
||||||
Okay
|
{'Okay'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default class RhsThread extends React.Component {
|
|||||||
}
|
}
|
||||||
getStateFromStores() {
|
getStateFromStores() {
|
||||||
var postList = PostStore.getSelectedPost();
|
var postList = PostStore.getSelectedPost();
|
||||||
if (!postList || postList.order.length < 1) {
|
if (!postList || postList.order.length < 1 || !postList.posts[postList.order[0]]) {
|
||||||
return {postList: {}};
|
return {postList: {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,10 @@ export default class RhsThread extends React.Component {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
$('.post-right__scroll').scrollTop($('.post-right__scroll')[0].scrollHeight);
|
if ($('.post-right__scroll')[0]) {
|
||||||
|
$('.post-right__scroll').scrollTop($('.post-right__scroll')[0].scrollHeight);
|
||||||
|
}
|
||||||
|
|
||||||
$('.post-right__scroll').perfectScrollbar('update');
|
$('.post-right__scroll').perfectScrollbar('update');
|
||||||
this.resize();
|
this.resize();
|
||||||
}
|
}
|
||||||
@@ -67,17 +70,10 @@ export default class RhsThread extends React.Component {
|
|||||||
// if something was changed in the channel like adding a
|
// if something was changed in the channel like adding a
|
||||||
// comment or post then lets refresh the sidebar list
|
// comment or post then lets refresh the sidebar list
|
||||||
var currentSelected = PostStore.getSelectedPost();
|
var currentSelected = PostStore.getSelectedPost();
|
||||||
if (!currentSelected || currentSelected.order.length === 0) {
|
if (!currentSelected || currentSelected.order.length === 0 || !currentSelected.posts[currentSelected.order[0]]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentSelected.posts[currentSelected.order[0]]) {
|
|
||||||
if ($('#post_deleted').length > 0) {
|
|
||||||
$('#post_deleted').modal('show');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentPosts = PostStore.getPosts(currentSelected.posts[currentSelected.order[0]].channel_id);
|
var currentPosts = PostStore.getPosts(currentSelected.posts[currentSelected.order[0]].channel_id);
|
||||||
|
|
||||||
if (!currentPosts || currentPosts.order.length === 0) {
|
if (!currentPosts || currentPosts.order.length === 0) {
|
||||||
@@ -110,7 +106,7 @@ export default class RhsThread extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
var postList = this.state.postList;
|
var postList = this.state.postList;
|
||||||
|
|
||||||
if (postList == null) {
|
if (postList == null || !postList.order) {
|
||||||
return (
|
return (
|
||||||
<div></div>
|
<div></div>
|
||||||
);
|
);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user