PLT-3221 Remove async call to get posts when creating a comment and editing a post (#3300)
PLT-3203 Commenting on the RHS while in permalink view makes the message not show up in the RHS
Этот коммит содержится в:
@@ -134,6 +134,7 @@ export function doFocusPost(channelId, postId, data) {
|
|||||||
AppDispatcher.handleServerAction({
|
AppDispatcher.handleServerAction({
|
||||||
type: ActionTypes.RECEIVED_FOCUSED_POST,
|
type: ActionTypes.RECEIVED_FOCUSED_POST,
|
||||||
postId,
|
postId,
|
||||||
|
channelId,
|
||||||
post_list: data
|
post_list: data
|
||||||
});
|
});
|
||||||
AsyncClient.getChannels(true);
|
AsyncClient.getChannels(true);
|
||||||
@@ -208,25 +209,25 @@ export function emitPostFocusRightHandSideFromSearch(post, isMentionSearch) {
|
|||||||
|
|
||||||
export function emitLoadMorePostsEvent() {
|
export function emitLoadMorePostsEvent() {
|
||||||
const id = ChannelStore.getCurrentId();
|
const id = ChannelStore.getCurrentId();
|
||||||
loadMorePostsTop(id);
|
loadMorePostsTop(id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emitLoadMorePostsFocusedTopEvent() {
|
export function emitLoadMorePostsFocusedTopEvent() {
|
||||||
const id = PostStore.getFocusedPostId();
|
const id = PostStore.getFocusedPostId();
|
||||||
loadMorePostsTop(id);
|
loadMorePostsTop(id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadMorePostsTop(id) {
|
export function loadMorePostsTop(id, isFocusPost) {
|
||||||
const earliestPostId = PostStore.getEarliestPost(id).id;
|
const earliestPostId = PostStore.getEarliestPost(id).id;
|
||||||
if (PostStore.requestVisibilityIncrease(id, Constants.POST_CHUNK_SIZE)) {
|
if (PostStore.requestVisibilityIncrease(id, Constants.POST_CHUNK_SIZE)) {
|
||||||
AsyncClient.getPostsBefore(earliestPostId, 0, Constants.POST_CHUNK_SIZE);
|
AsyncClient.getPostsBefore(earliestPostId, 0, Constants.POST_CHUNK_SIZE, isFocusPost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emitLoadMorePostsFocusedBottomEvent() {
|
export function emitLoadMorePostsFocusedBottomEvent() {
|
||||||
const id = PostStore.getFocusedPostId();
|
const id = PostStore.getFocusedPostId();
|
||||||
const latestPostId = PostStore.getLatestPost(id).id;
|
const latestPostId = PostStore.getLatestPost(id).id;
|
||||||
AsyncClient.getPostsAfter(latestPostId, 0, Constants.POST_CHUNK_SIZE);
|
AsyncClient.getPostsAfter(latestPostId, 0, Constants.POST_CHUNK_SIZE, !!id);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emitPostRecievedEvent(post, msg) {
|
export function emitPostRecievedEvent(post, msg) {
|
||||||
@@ -259,6 +260,13 @@ export function emitUserPostedEvent(post) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function emitUserCommentedEvent(post) {
|
||||||
|
AppDispatcher.handleServerAction({
|
||||||
|
type: ActionTypes.CREATE_COMMENT,
|
||||||
|
post
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function emitPostDeletedEvent(post) {
|
export function emitPostDeletedEvent(post) {
|
||||||
AppDispatcher.handleServerAction({
|
AppDispatcher.handleServerAction({
|
||||||
type: ActionTypes.POST_DELETED,
|
type: ActionTypes.POST_DELETED,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import $ from 'jquery';
|
|||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
||||||
import Client from 'utils/web_client.jsx';
|
import Client from 'utils/web_client.jsx';
|
||||||
import ChannelStore from 'stores/channel_store.jsx';
|
|
||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
import PostDeletedModal from './post_deleted_modal.jsx';
|
import PostDeletedModal from './post_deleted_modal.jsx';
|
||||||
import PostStore from 'stores/post_store.jsx';
|
import PostStore from 'stores/post_store.jsx';
|
||||||
@@ -144,22 +143,11 @@ class CreateComment extends React.Component {
|
|||||||
post.user_id = userId;
|
post.user_id = userId;
|
||||||
post.create_at = time;
|
post.create_at = time;
|
||||||
|
|
||||||
PostStore.storePendingPost(post);
|
GlobalActions.emitUserCommentedEvent(post);
|
||||||
PostStore.storeCommentDraft(this.props.rootId, null);
|
|
||||||
|
|
||||||
Client.createPost(
|
Client.createPost(
|
||||||
post,
|
post,
|
||||||
(data) => {
|
() => {
|
||||||
const channel = ChannelStore.get(this.props.channelId);
|
// DO nothing. Websockets will handle this.
|
||||||
const member = ChannelStore.getMember(this.props.channelId);
|
|
||||||
member.msg_count = channel.total_msg_count;
|
|
||||||
member.last_viewed_at = Date.now();
|
|
||||||
ChannelStore.setChannelMember(member);
|
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECEIVED_POST,
|
|
||||||
post: data
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err.id === 'api.post.create_post.root_id.app_error') {
|
if (err.id === 'api.post.create_post.root_id.app_error') {
|
||||||
|
|||||||
@@ -137,7 +137,10 @@ export default class PostList extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadMorePostsTop() {
|
loadMorePostsTop() {
|
||||||
GlobalActions.emitLoadMorePostsEvent();
|
if (this.props.isFocusPost) {
|
||||||
|
return GlobalActions.emitLoadMorePostsFocusedTopEvent();
|
||||||
|
}
|
||||||
|
return GlobalActions.emitLoadMorePostsEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMorePostsBottom() {
|
loadMorePostsBottom() {
|
||||||
@@ -522,5 +525,6 @@ PostList.propTypes = {
|
|||||||
displayNameType: React.PropTypes.string,
|
displayNameType: React.PropTypes.string,
|
||||||
displayPostsInCenter: React.PropTypes.bool,
|
displayPostsInCenter: React.PropTypes.bool,
|
||||||
compactDisplay: React.PropTypes.bool,
|
compactDisplay: React.PropTypes.bool,
|
||||||
previewsCollapsed: React.PropTypes.string
|
previewsCollapsed: React.PropTypes.string,
|
||||||
|
isFocusPost: React.PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ export default class PostFocusView extends React.Component {
|
|||||||
showMoreMessagesTop={!this.state.atTop}
|
showMoreMessagesTop={!this.state.atTop}
|
||||||
showMoreMessagesBottom={!this.state.atBottom}
|
showMoreMessagesBottom={!this.state.atBottom}
|
||||||
postsToHighlight={postsToHighlight}
|
postsToHighlight={postsToHighlight}
|
||||||
|
isFocusPost={true}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,13 +231,14 @@ class PostStoreClass extends EventEmitter {
|
|||||||
this.postsInfo[post.channel_id].postList = postList;
|
this.postsInfo[post.channel_id].postList = postList;
|
||||||
}
|
}
|
||||||
|
|
||||||
storeFocusedPost(postId, postList) {
|
storeFocusedPost(postId, channelId, postList) {
|
||||||
const focusedPost = postList.posts[postId];
|
const focusedPost = postList.posts[postId];
|
||||||
if (!focusedPost) {
|
if (!focusedPost) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.currentFocusedPostId = postId;
|
this.currentFocusedPostId = postId;
|
||||||
this.storePosts(postId, postList);
|
this.storePosts(postId, postList);
|
||||||
|
this.storePosts(channelId, postList);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBounds(id, numRequested, postList, before) {
|
checkBounds(id, numRequested, postList, before) {
|
||||||
@@ -407,11 +408,11 @@ class PostStoreClass extends EventEmitter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let posts;
|
const posts = {};
|
||||||
let pendingPosts;
|
let pendingPosts;
|
||||||
for (const k in this.postsInfo) {
|
for (const k in this.postsInfo) {
|
||||||
if (this.postsInfo[k].postList && this.postsInfo[k].postList.posts.hasOwnProperty(this.selectedPostId)) {
|
if (this.postsInfo[k].postList && this.postsInfo[k].postList.posts.hasOwnProperty(this.selectedPostId)) {
|
||||||
posts = this.postsInfo[k].postList.posts;
|
Object.assign(posts, this.postsInfo[k].postList.posts);
|
||||||
if (this.postsInfo[k].pendingPosts != null) {
|
if (this.postsInfo[k].pendingPosts != null) {
|
||||||
pendingPosts = this.postsInfo[k].pendingPosts.posts;
|
pendingPosts = this.postsInfo[k].pendingPosts.posts;
|
||||||
}
|
}
|
||||||
@@ -559,7 +560,7 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
}
|
}
|
||||||
case ActionTypes.RECEIVED_FOCUSED_POST:
|
case ActionTypes.RECEIVED_FOCUSED_POST:
|
||||||
PostStore.clearChannelVisibility(action.postId, false);
|
PostStore.clearChannelVisibility(action.postId, false);
|
||||||
PostStore.storeFocusedPost(action.postId, makePostListNonNull(action.post_list));
|
PostStore.storeFocusedPost(action.postId, action.channelId, makePostListNonNull(action.post_list));
|
||||||
PostStore.emitChange();
|
PostStore.emitChange();
|
||||||
break;
|
break;
|
||||||
case ActionTypes.RECEIVED_POST:
|
case ActionTypes.RECEIVED_POST:
|
||||||
@@ -579,6 +580,10 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
PostStore.storeDraft(action.post.channel_id, null);
|
PostStore.storeDraft(action.post.channel_id, null);
|
||||||
PostStore.jumpPostsViewToBottom();
|
PostStore.jumpPostsViewToBottom();
|
||||||
break;
|
break;
|
||||||
|
case ActionTypes.CREATE_COMMENT:
|
||||||
|
PostStore.storePendingPost(action.post);
|
||||||
|
PostStore.storeCommentDraft(action.post.root_id, null);
|
||||||
|
break;
|
||||||
case ActionTypes.POST_DELETED:
|
case ActionTypes.POST_DELETED:
|
||||||
PostStore.deletePost(action.post);
|
PostStore.deletePost(action.post);
|
||||||
PostStore.emitChange();
|
PostStore.emitChange();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export default {
|
|||||||
CREATE_CHANNEL: null,
|
CREATE_CHANNEL: null,
|
||||||
LEAVE_CHANNEL: null,
|
LEAVE_CHANNEL: null,
|
||||||
CREATE_POST: null,
|
CREATE_POST: null,
|
||||||
|
CREATE_COMMENT: null,
|
||||||
POST_DELETED: null,
|
POST_DELETED: null,
|
||||||
REMOVE_POST: null,
|
REMOVE_POST: null,
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user