Fix deleting threads
Этот коммит содержится в:
@@ -21,9 +21,6 @@ export default class DeletePostModal extends React.Component {
|
|||||||
this.handleDelete = this.handleDelete.bind(this);
|
this.handleDelete = this.handleDelete.bind(this);
|
||||||
this.handleToggle = this.handleToggle.bind(this);
|
this.handleToggle = this.handleToggle.bind(this);
|
||||||
this.handleHide = this.handleHide.bind(this);
|
this.handleHide = this.handleHide.bind(this);
|
||||||
this.onListenerChange = this.onListenerChange.bind(this);
|
|
||||||
|
|
||||||
this.selectedList = null;
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
show: false,
|
show: false,
|
||||||
@@ -35,11 +32,9 @@ export default class DeletePostModal extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
ModalStore.addModalListener(ActionTypes.TOGGLE_DELETE_POST_MODAL, this.handleToggle);
|
ModalStore.addModalListener(ActionTypes.TOGGLE_DELETE_POST_MODAL, this.handleToggle);
|
||||||
PostStore.addSelectedPostChangeListener(this.onListenerChange);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
PostStore.removeSelectedPostChangeListener(this.onListenerChange);
|
|
||||||
ModalStore.removeModalListener(ActionTypes.TOGGLE_DELETE_POST_MODAL, this.handleToggle);
|
ModalStore.removeModalListener(ActionTypes.TOGGLE_DELETE_POST_MODAL, this.handleToggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,40 +51,15 @@ export default class DeletePostModal extends React.Component {
|
|||||||
this.state.post.channel_id,
|
this.state.post.channel_id,
|
||||||
this.state.post.id,
|
this.state.post.id,
|
||||||
() => {
|
() => {
|
||||||
var selectedList = this.selectedList;
|
|
||||||
|
|
||||||
if (selectedList && selectedList.order && selectedList.order.length > 0) {
|
|
||||||
var selectedPost = selectedList.posts[selectedList.order[0]];
|
|
||||||
if ((selectedPost.id === this.state.post.id && !this.state.root_id) || selectedPost.root_id === this.state.post.id) {
|
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECEIVED_SEARCH,
|
|
||||||
results: null
|
|
||||||
});
|
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECEIVED_POST_SELECTED,
|
|
||||||
postId: null
|
|
||||||
});
|
|
||||||
} else if (selectedPost.id === this.state.post.id && this.state.root_id) {
|
|
||||||
if (selectedPost.root_id && selectedPost.root_id.length > 0 && selectedList.posts[selectedPost.root_id]) {
|
|
||||||
selectedList.order = [selectedPost.root_id];
|
|
||||||
delete selectedList.posts[selectedPost.id];
|
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECEIVED_POST_SELECTED,
|
|
||||||
postId: selectedPost.root_id
|
|
||||||
});
|
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECEIVED_SEARCH,
|
|
||||||
results: null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PostStore.deletePost(this.state.post);
|
PostStore.deletePost(this.state.post);
|
||||||
AsyncClient.getPosts(this.state.post.channel_id);
|
AsyncClient.getPosts(this.state.post.channel_id);
|
||||||
|
|
||||||
|
if (this.state.post.id === PostStore.getSelectedPostId()) {
|
||||||
|
AppDispatcher.handleServerAction({
|
||||||
|
type: ActionTypes.RECEIVED_POST_SELECTED,
|
||||||
|
postId: null
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
AsyncClient.dispatchError(err, 'deletePost');
|
AsyncClient.dispatchError(err, 'deletePost');
|
||||||
@@ -112,13 +82,6 @@ export default class DeletePostModal extends React.Component {
|
|||||||
this.setState({show: false});
|
this.setState({show: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
onListenerChange() {
|
|
||||||
var newList = PostStore.getSelectedPost();
|
|
||||||
if (!Utils.areObjectsEqual(this.selectedList, newList)) {
|
|
||||||
this.selectedList = newList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (!this.state.post) {
|
if (!this.state.post) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -91,9 +91,11 @@ export default class RhsThread extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
onPostChange() {
|
onPostChange() {
|
||||||
const selected = PostStore.getSelectedPost();
|
if (this.mounted) {
|
||||||
const posts = PostStore.getSelectedPostThread();
|
const selected = PostStore.getSelectedPost();
|
||||||
this.setState({posts, selected});
|
const posts = PostStore.getSelectedPostThread();
|
||||||
|
this.setState({posts, selected});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onUserChange() {
|
onUserChange() {
|
||||||
const profiles = JSON.parse(JSON.stringify(UserStore.getProfiles()));
|
const profiles = JSON.parse(JSON.stringify(UserStore.getProfiles()));
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user