Merge pull request #761 from mattermost/plt-356
PLT-356 Fix post not rendering properly in some cases.
Этот коммит содержится в:
@@ -51,7 +51,7 @@ export default class Post extends React.Component {
|
|||||||
|
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
client.createPost(post, post.channel_id,
|
client.createPost(post, post.channel_id,
|
||||||
function success(data) {
|
(data) => {
|
||||||
AsyncClient.getPosts();
|
AsyncClient.getPosts();
|
||||||
|
|
||||||
var channel = ChannelStore.get(post.channel_id);
|
var channel = ChannelStore.get(post.channel_id);
|
||||||
@@ -65,11 +65,11 @@ export default class Post extends React.Component {
|
|||||||
post: data
|
post: data
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function error() {
|
() => {
|
||||||
post.state = Constants.POST_FAILED;
|
post.state = Constants.POST_FAILED;
|
||||||
PostStore.updatePendingPost(post);
|
PostStore.updatePendingPost(post);
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}.bind(this)
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
post.state = Constants.POST_LOADING;
|
post.state = Constants.POST_LOADING;
|
||||||
@@ -81,8 +81,40 @@ export default class Post extends React.Component {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nextProps.sameRoot !== this.props.sameRoot) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextProps.sameUser !== this.props.sameUser) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getCommentCount(nextProps) !== this.getCommentCount(this.props)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
getCommentCount(props) {
|
||||||
|
const post = props.post;
|
||||||
|
const parentPost = props.parentPost;
|
||||||
|
const posts = props.posts;
|
||||||
|
|
||||||
|
let commentCount = 0;
|
||||||
|
let commentRootId;
|
||||||
|
if (parentPost) {
|
||||||
|
commentRootId = post.root_id;
|
||||||
|
} else {
|
||||||
|
commentRootId = post.id;
|
||||||
|
}
|
||||||
|
for (let postId in posts) {
|
||||||
|
if (posts[postId].root_id === commentRootId) {
|
||||||
|
commentCount += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return commentCount;
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
var parentPost = this.props.parentPost;
|
var parentPost = this.props.parentPost;
|
||||||
@@ -93,18 +125,7 @@ export default class Post extends React.Component {
|
|||||||
type = 'Comment';
|
type = 'Comment';
|
||||||
}
|
}
|
||||||
|
|
||||||
var commentCount = 0;
|
const commentCount = this.getCommentCount(this.props);
|
||||||
var commentRootId;
|
|
||||||
if (parentPost) {
|
|
||||||
commentRootId = post.root_id;
|
|
||||||
} else {
|
|
||||||
commentRootId = post.id;
|
|
||||||
}
|
|
||||||
for (var postId in posts) {
|
|
||||||
if (posts[postId].root_id === commentRootId) {
|
|
||||||
commentCount += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var rootUser;
|
var rootUser;
|
||||||
if (this.props.sameRoot) {
|
if (this.props.sameRoot) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user