Fix RHS not closing when thread is deleted by another user (#3641)
Этот коммит содержится в:
коммит произвёл
enahum
родитель
022cb7ffa1
Коммит
d1de884845
@@ -159,6 +159,11 @@ function handlePostEditEvent(msg) {
|
|||||||
function handlePostDeleteEvent(msg) {
|
function handlePostDeleteEvent(msg) {
|
||||||
const post = JSON.parse(msg.data.post);
|
const post = JSON.parse(msg.data.post);
|
||||||
GlobalActions.emitPostDeletedEvent(post);
|
GlobalActions.emitPostDeletedEvent(post);
|
||||||
|
|
||||||
|
const selectedPostId = PostStore.getSelectedPostId();
|
||||||
|
if (selectedPostId === post.id) {
|
||||||
|
GlobalActions.emitCloseRightHandSide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleNewUserEvent() {
|
function handleNewUserEvent() {
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import $ from 'jquery';
|
|
||||||
import PostStore from 'stores/post_store.jsx';
|
|
||||||
import UserStore from 'stores/user_store.jsx';
|
|
||||||
import PreferenceStore from 'stores/preference_store.jsx';
|
|
||||||
import * as Utils from 'utils/utils.jsx';
|
|
||||||
import SearchBox from './search_bar.jsx';
|
import SearchBox from './search_bar.jsx';
|
||||||
import CreateComment from './create_comment.jsx';
|
import CreateComment from './create_comment.jsx';
|
||||||
import RhsHeaderPost from './rhs_header_post.jsx';
|
import RhsHeaderPost from './rhs_header_post.jsx';
|
||||||
import RootPost from './rhs_root_post.jsx';
|
import RootPost from './rhs_root_post.jsx';
|
||||||
import Comment from './rhs_comment.jsx';
|
import Comment from './rhs_comment.jsx';
|
||||||
|
import FileUploadOverlay from './file_upload_overlay.jsx';
|
||||||
|
|
||||||
|
import PostStore from 'stores/post_store.jsx';
|
||||||
|
import UserStore from 'stores/user_store.jsx';
|
||||||
|
import PreferenceStore from 'stores/preference_store.jsx';
|
||||||
|
|
||||||
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
|
||||||
import Constants from 'utils/constants.jsx';
|
import Constants from 'utils/constants.jsx';
|
||||||
const Preferences = Constants.Preferences;
|
const Preferences = Constants.Preferences;
|
||||||
import FileUploadOverlay from './file_upload_overlay.jsx';
|
|
||||||
import Scrollbars from 'react-custom-scrollbars';
|
|
||||||
|
|
||||||
|
import $ from 'jquery';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import Scrollbars from 'react-custom-scrollbars';
|
||||||
|
|
||||||
export function renderView(props) {
|
export function renderView(props) {
|
||||||
return (
|
return (
|
||||||
@@ -62,6 +65,7 @@ export default class RhsThread extends React.Component {
|
|||||||
|
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
PostStore.addSelectedPostChangeListener(this.onPostChange);
|
PostStore.addSelectedPostChangeListener(this.onPostChange);
|
||||||
PostStore.addChangeListener(this.onPostChange);
|
PostStore.addChangeListener(this.onPostChange);
|
||||||
@@ -73,6 +77,7 @@ export default class RhsThread extends React.Component {
|
|||||||
|
|
||||||
this.mounted = true;
|
this.mounted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
PostStore.removeSelectedPostChangeListener(this.onPostChange);
|
PostStore.removeSelectedPostChangeListener(this.onPostChange);
|
||||||
PostStore.removeChangeListener(this.onPostChange);
|
PostStore.removeChangeListener(this.onPostChange);
|
||||||
@@ -83,6 +88,7 @@ export default class RhsThread extends React.Component {
|
|||||||
|
|
||||||
this.mounted = false;
|
this.mounted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
const prevPostsArray = prevState.postsArray || [];
|
const prevPostsArray = prevState.postsArray || [];
|
||||||
const curPostsArray = this.state.postsArray || [];
|
const curPostsArray = this.state.postsArray || [];
|
||||||
@@ -97,6 +103,7 @@ export default class RhsThread extends React.Component {
|
|||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
if (!Utils.areObjectsEqual(nextState.postsArray, this.state.postsArray)) {
|
if (!Utils.areObjectsEqual(nextState.postsArray, this.state.postsArray)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -124,6 +131,7 @@ export default class RhsThread extends React.Component {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
forceUpdateInfo() {
|
forceUpdateInfo() {
|
||||||
if (this.state.postList) {
|
if (this.state.postList) {
|
||||||
for (var postId in this.state.postList.posts) {
|
for (var postId in this.state.postList.posts) {
|
||||||
@@ -133,23 +141,27 @@ export default class RhsThread extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResize() {
|
handleResize() {
|
||||||
this.setState({
|
this.setState({
|
||||||
windowWidth: Utils.windowWidth(),
|
windowWidth: Utils.windowWidth(),
|
||||||
windowHeight: Utils.windowHeight()
|
windowHeight: Utils.windowHeight()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onPreferenceChange() {
|
onPreferenceChange() {
|
||||||
this.setState({
|
this.setState({
|
||||||
compactDisplay: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.MESSAGE_DISPLAY, Preferences.MESSAGE_DISPLAY_DEFAULT) === Preferences.MESSAGE_DISPLAY_COMPACT
|
compactDisplay: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.MESSAGE_DISPLAY, Preferences.MESSAGE_DISPLAY_DEFAULT) === Preferences.MESSAGE_DISPLAY_COMPACT
|
||||||
});
|
});
|
||||||
this.forceUpdateInfo();
|
this.forceUpdateInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
onPostChange() {
|
onPostChange() {
|
||||||
if (this.mounted) {
|
if (this.mounted) {
|
||||||
this.setState(this.getPosts());
|
this.setState(this.getPosts());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPosts() {
|
getPosts() {
|
||||||
const selected = PostStore.getSelectedPost();
|
const selected = PostStore.getSelectedPost();
|
||||||
const posts = PostStore.getSelectedPostThread();
|
const posts = PostStore.getSelectedPostThread();
|
||||||
@@ -192,15 +204,18 @@ export default class RhsThread extends React.Component {
|
|||||||
|
|
||||||
return {postsArray, selected};
|
return {postsArray, selected};
|
||||||
}
|
}
|
||||||
|
|
||||||
onUserChange() {
|
onUserChange() {
|
||||||
const profiles = JSON.parse(JSON.stringify(UserStore.getProfiles()));
|
const profiles = JSON.parse(JSON.stringify(UserStore.getProfiles()));
|
||||||
this.setState({profiles});
|
this.setState({profiles});
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToBottom() {
|
scrollToBottom() {
|
||||||
if ($('.post-right__scroll')[0]) {
|
if ($('.post-right__scroll')[0]) {
|
||||||
$('.post-right__scroll').parent().scrollTop($('.post-right__scroll')[0].scrollHeight);
|
$('.post-right__scroll').parent().scrollTop($('.post-right__scroll')[0].scrollHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const postsArray = this.state.postsArray;
|
const postsArray = this.state.postsArray;
|
||||||
const selected = this.state.selected;
|
const selected = this.state.selected;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user