From 3a6694cc6b52ba0022a92373df9f07b7bf080240 Mon Sep 17 00:00:00 2001 From: enahum Date: Tue, 7 Jun 2016 18:43:36 -0300 Subject: PLT-3203 Commenting on the RHS while in permalink view makes the message not show up in the RHS (#3282) --- webapp/actions/global_actions.jsx | 4 ++-- webapp/components/create_comment.jsx | 3 +++ webapp/components/edit_post_modal.jsx | 1 + webapp/stores/post_store.jsx | 2 +- webapp/utils/async_client.jsx | 10 ++++++---- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx index 0b264a9b3..165d655e4 100644 --- a/webapp/actions/global_actions.jsx +++ b/webapp/actions/global_actions.jsx @@ -138,8 +138,8 @@ export function doFocusPost(channelId, postId, data) { }); AsyncClient.getChannels(true); AsyncClient.getChannelExtraInfo(channelId); - AsyncClient.getPostsBefore(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS); - AsyncClient.getPostsAfter(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS); + AsyncClient.getPostsBefore(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS, true); + AsyncClient.getPostsAfter(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS, true); } export function emitPostFocusEvent(postId) { diff --git a/webapp/components/create_comment.jsx b/webapp/components/create_comment.jsx index 73758e73c..a9cf68833 100644 --- a/webapp/components/create_comment.jsx +++ b/webapp/components/create_comment.jsx @@ -5,6 +5,7 @@ import $ from 'jquery'; import ReactDOM from 'react-dom'; import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; import Client from 'utils/web_client.jsx'; +import * as AsyncClient from 'utils/async_client.jsx'; import ChannelStore from 'stores/channel_store.jsx'; import UserStore from 'stores/user_store.jsx'; import PostDeletedModal from './post_deleted_modal.jsx'; @@ -150,6 +151,8 @@ class CreateComment extends React.Component { Client.createPost( post, (data) => { + AsyncClient.getPosts(this.props.channelId); + const channel = ChannelStore.get(this.props.channelId); const member = ChannelStore.getMember(this.props.channelId); member.msg_count = channel.total_msg_count; diff --git a/webapp/components/edit_post_modal.jsx b/webapp/components/edit_post_modal.jsx index bdd540b09..4bd23a26d 100644 --- a/webapp/components/edit_post_modal.jsx +++ b/webapp/components/edit_post_modal.jsx @@ -67,6 +67,7 @@ class EditPostModal extends React.Component { Client.updatePost( updatedPost, () => { + AsyncClient.getPosts(updatedPost.channel_id); window.scrollTo(0, 0); }, (err) => { diff --git a/webapp/stores/post_store.jsx b/webapp/stores/post_store.jsx index 062997f2b..b5e73b6b4 100644 --- a/webapp/stores/post_store.jsx +++ b/webapp/stores/post_store.jsx @@ -551,7 +551,7 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => { switch (action.type) { case ActionTypes.RECEIVED_POSTS: { - const id = PostStore.currentFocusedPostId == null ? action.id : PostStore.currentFocusedPostId; + const id = PostStore.currentFocusedPostId !== null && action.isPost ? PostStore.currentFocusedPostId : action.id; PostStore.storePosts(id, makePostListNonNull(action.post_list)); PostStore.checkBounds(id, action.numRequested, makePostListNonNull(action.post_list), action.before); PostStore.emitChange(); diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index 6f5f8a2cd..65cb2d258 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -603,7 +603,7 @@ export function getPosts(id) { ); } -export function getPostsBefore(postId, offset, numPost) { +export function getPostsBefore(postId, offset, numPost, isPost) { const channelId = ChannelStore.getCurrentId(); if (channelId == null) { return; @@ -624,7 +624,8 @@ export function getPostsBefore(postId, offset, numPost) { id: channelId, before: true, numRequested: numPost, - post_list: data + post_list: data, + isPost }); getProfiles(); @@ -638,7 +639,7 @@ export function getPostsBefore(postId, offset, numPost) { ); } -export function getPostsAfter(postId, offset, numPost) { +export function getPostsAfter(postId, offset, numPost, isPost) { const channelId = ChannelStore.getCurrentId(); if (channelId == null) { return; @@ -659,7 +660,8 @@ export function getPostsAfter(postId, offset, numPost) { id: channelId, before: false, numRequested: numPost, - post_list: data + post_list: data, + isPost }); getProfiles(); -- cgit v1.2.3-1-g7c22