reformatted post_right to match style guide more closely
Этот коммит содержится в:
@@ -127,7 +127,7 @@ RootPost = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div className="post-body">
|
<div className='post-body'>
|
||||||
<p>{message}</p>
|
<p>{message}</p>
|
||||||
{fileAttachment}
|
{fileAttachment}
|
||||||
</div>
|
</div>
|
||||||
@@ -144,13 +144,13 @@ CommentPost = React.createClass({
|
|||||||
|
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
client.createPost(post, post.channel_id,
|
client.createPost(post, post.channel_id,
|
||||||
function(data) {
|
function success(data) {
|
||||||
AsyncClient.getPosts(true);
|
AsyncClient.getPosts(true);
|
||||||
|
|
||||||
var channel = ChannelStore.get(post.channel_id);
|
var channel = ChannelStore.get(post.channel_id);
|
||||||
var member = ChannelStore.getMember(post.channel_id);
|
var member = ChannelStore.getMember(post.channel_id);
|
||||||
member.msg_count = channel.total_msg_count;
|
member.msg_count = channel.total_msg_count;
|
||||||
member.last_viewed_at = (new Date).getTime();
|
member.last_viewed_at = (new Date()).getTime();
|
||||||
ChannelStore.setChannelMember(member);
|
ChannelStore.setChannelMember(member);
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
AppDispatcher.handleServerAction({
|
||||||
@@ -158,7 +158,7 @@ CommentPost = React.createClass({
|
|||||||
post: data
|
post: data
|
||||||
});
|
});
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
function(err) {
|
function fail() {
|
||||||
post.state = Constants.POST_FAILED;
|
post.state = Constants.POST_FAILED;
|
||||||
PostStore.updatePendingPost(post);
|
PostStore.updatePendingPost(post);
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
@@ -234,7 +234,7 @@ CommentPost = React.createClass({
|
|||||||
{ownerOptions}
|
{ownerOptions}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div className="post-body">
|
<div className='post-body'>
|
||||||
<p className={postClass}>{loading}{message}</p>
|
<p className={postClass}>{loading}{message}</p>
|
||||||
{fileAttachment}
|
{fileAttachment}
|
||||||
</div>
|
</div>
|
||||||
@@ -245,24 +245,28 @@ CommentPost = React.createClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function getStateFromStores() {
|
function getStateFromStores() {
|
||||||
var post_list = PostStore.getSelectedPost();
|
var postList = PostStore.getSelectedPost();
|
||||||
if (!post_list || post_list.order.length < 1) return { post_list: {} };
|
if (!postList || postList.order.length < 1) {
|
||||||
|
return {postList: {}};
|
||||||
var channel_id = post_list.posts[post_list.order[0]].channel_id;
|
|
||||||
var pending_post_list = PostStore.getPendingPosts(channel_id);
|
|
||||||
|
|
||||||
if (pending_post_list) {
|
|
||||||
for (var pid in pending_post_list.posts) { post_list.posts[pid] = pending_post_list.posts[pid] };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { post_list: post_list };
|
var channelId = postList.posts[postList.order[0]].channel_id;
|
||||||
|
var pendingPostList = PostStore.getPendingPosts(channelId);
|
||||||
|
|
||||||
|
if (pendingPostList) {
|
||||||
|
for (var pid in pendingPostList.posts) {
|
||||||
|
postList.posts[pid] = pendingPostList.posts[pid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {postList: postList};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
PostStore.addSelectedPostChangeListener(this._onChange);
|
PostStore.addSelectedPostChangeListener(this.onChange);
|
||||||
PostStore.addChangeListener(this._onChangeAll);
|
PostStore.addChangeListener(this.onChangeAll);
|
||||||
UserStore.addStatusesChangeListener(this._onTimeChange);
|
UserStore.addStatusesChangeListener(this.onTimeChange);
|
||||||
this.resize();
|
this.resize();
|
||||||
var self = this;
|
var self = this;
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
@@ -275,11 +279,11 @@ module.exports = React.createClass({
|
|||||||
this.resize();
|
this.resize();
|
||||||
},
|
},
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
PostStore.removeSelectedPostChangeListener(this._onChange);
|
PostStore.removeSelectedPostChangeListener(this.onChange);
|
||||||
PostStore.removeChangeListener(this._onChangeAll);
|
PostStore.removeChangeListener(this.onChangeAll);
|
||||||
UserStore.removeStatusesChangeListener(this._onTimeChange);
|
UserStore.removeStatusesChangeListener(this.onTimeChange);
|
||||||
},
|
},
|
||||||
_onChange: function() {
|
onChange: function() {
|
||||||
if (this.isMounted()) {
|
if (this.isMounted()) {
|
||||||
var newState = getStateFromStores();
|
var newState = getStateFromStores();
|
||||||
if (!utils.areStatesEqual(newState, this.state)) {
|
if (!utils.areStatesEqual(newState, this.state)) {
|
||||||
@@ -287,24 +291,22 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_onChangeAll: function() {
|
onChangeAll: function() {
|
||||||
if (this.isMounted()) {
|
if (this.isMounted()) {
|
||||||
|
|
||||||
// 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) {
|
||||||
return;
|
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) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentPosts.posts[currentPosts.order[0]].channel_id === currentSelected.posts[currentSelected.order[0]].channel_id) {
|
||||||
if (currentPosts.posts[currentPosts.order[0]].channel_id == currentSelected.posts[currentSelected.order[0]].channel_id) {
|
|
||||||
currentSelected.posts = {};
|
currentSelected.posts = {};
|
||||||
for (var postId in currentPosts.posts) {
|
for (var postId in currentPosts.posts) {
|
||||||
currentSelected.posts[postId] = currentPosts.posts[postId];
|
currentSelected.posts[postId] = currentPosts.posts[postId];
|
||||||
@@ -316,9 +318,11 @@ module.exports = React.createClass({
|
|||||||
this.setState(getStateFromStores());
|
this.setState(getStateFromStores());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_onTimeChange: function() {
|
onTimeChange: function() {
|
||||||
for (var id in this.state.post_list.posts) {
|
for (var id in this.state.postList.posts) {
|
||||||
if (!this.refs[id]) continue;
|
if (!this.refs[id]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
this.refs[id].forceUpdate();
|
this.refs[id].forceUpdate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -333,45 +337,47 @@ module.exports = React.createClass({
|
|||||||
$('.post-right__scroll').perfectScrollbar('update');
|
$('.post-right__scroll').perfectScrollbar('update');
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
var postList = this.state.postList;
|
||||||
|
|
||||||
var post_list = this.state.post_list;
|
if (postList == null) {
|
||||||
|
|
||||||
if (post_list == null) {
|
|
||||||
return (
|
return (
|
||||||
<div></div>
|
<div></div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var selected_post = post_list.posts[post_list.order[0]];
|
var selectedPost = postList.posts[postList.order[0]];
|
||||||
var root_post = null;
|
var rootPost = null;
|
||||||
|
|
||||||
if (selected_post.root_id == '') {
|
if (selectedPost.root_id === '') {
|
||||||
root_post = selected_post;
|
rootPost = selectedPost;
|
||||||
}
|
} else {
|
||||||
else {
|
rootPost = postList.posts[selectedPost.root_id];
|
||||||
root_post = post_list.posts[selected_post.root_id];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var posts_array = [];
|
var postsArray = [];
|
||||||
|
|
||||||
for (var postId in post_list.posts) {
|
for (var postId in postList.posts) {
|
||||||
var cpost = post_list.posts[postId];
|
var cpost = postList.posts[postId];
|
||||||
if (cpost.root_id == root_post.id) {
|
if (cpost.root_id === rootPost.id) {
|
||||||
posts_array.push(cpost);
|
postsArray.push(cpost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
posts_array.sort(function(a,b) {
|
postsArray.sort(function postSort(a, b) {
|
||||||
if (a.create_at < b.create_at)
|
if (a.create_at < b.create_at) {
|
||||||
return -1;
|
return -1;
|
||||||
if (a.create_at > b.create_at)
|
}
|
||||||
|
if (a.create_at > b.create_at) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
var results = this.state.results;
|
|
||||||
var currentId = UserStore.getCurrentId();
|
var currentId = UserStore.getCurrentId();
|
||||||
var searchForm = currentId == null ? null : <SearchBox />;
|
var searchForm;
|
||||||
|
if (currentId != null) {
|
||||||
|
searchForm = <SearchBox />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='post-right__container'>
|
<div className='post-right__container'>
|
||||||
@@ -380,15 +386,15 @@ module.exports = React.createClass({
|
|||||||
<div className='search-bar__container sidebar--right__search-header'>{searchForm}</div>
|
<div className='search-bar__container sidebar--right__search-header'>{searchForm}</div>
|
||||||
<div className='sidebar-right__body'>
|
<div className='sidebar-right__body'>
|
||||||
<RhsHeaderPost fromSearch={this.props.fromSearch} isMentionSearch={this.props.isMentionSearch} />
|
<RhsHeaderPost fromSearch={this.props.fromSearch} isMentionSearch={this.props.isMentionSearch} />
|
||||||
<div className="post-right__scroll">
|
<div className='post-right__scroll'>
|
||||||
<RootPost post={root_post} commentCount={posts_array.length}/>
|
<RootPost post={rootPost} commentCount={postsArray.length}/>
|
||||||
<div className="post-right-comments-container">
|
<div className='post-right-comments-container'>
|
||||||
{ posts_array.map(function(cpost) {
|
{postsArray.map(function mapPosts(comPost) {
|
||||||
return <CommentPost ref={cpost.id} key={cpost.id} post={cpost} selected={ (cpost.id == selected_post.id) } />
|
return <CommentPost ref={comPost.id} key={comPost.id} post={comPost} selected={(comPost.id === selectedPost.id)} />;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<div className='post-create__container'>
|
<div className='post-create__container'>
|
||||||
<CreateComment channelId={root_post.channel_id} rootId={root_post.id} />
|
<CreateComment channelId={rootPost.channel_id} rootId={rootPost.id} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user