From 4efb0f37b701aa8e875e541cc4f121c264e4d8ab Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 5 Jul 2017 16:20:25 -0400 Subject: Increase post visibility in current channel when receiving posts (#6848) --- webapp/actions/post_actions.jsx | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx index b9d6934d8..43204a543 100644 --- a/webapp/actions/post_actions.jsx +++ b/webapp/actions/post_actions.jsx @@ -54,26 +54,7 @@ function completePostReceive(post, websocketMessageProps) { if (post.root_id && Selectors.getPost(getState(), post.root_id) == null) { PostActions.getPostThread(post.root_id)(dispatch, getState).then( (data) => { - // Need manual dispatch to remove pending post - dispatch({ - type: PostTypes.RECEIVED_POSTS, - data: { - order: [], - posts: { - [post.id]: post - } - }, - channelId: post.channel_id - }); - - // Still needed to update unreads - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_POST, - post, - websocketMessageProps - }); - - sendDesktopNotification(post, websocketMessageProps); + dispatchPostActions(post, websocketMessageProps); loadProfilesForPosts(data.posts); } ); @@ -81,6 +62,21 @@ function completePostReceive(post, websocketMessageProps) { return; } + dispatchPostActions(post, websocketMessageProps); +} + +function dispatchPostActions(post, websocketMessageProps) { + const {currentChannelId} = getState().entities.channels; + + if (post.channel_id === currentChannelId) { + dispatch({ + type: ActionTypes.INCREASE_POST_VISIBILITY, + data: post.channel_id, + amount: 1 + }); + } + + // Need manual dispatch to remove pending post dispatch({ type: PostTypes.RECEIVED_POSTS, data: { -- cgit v1.2.3-1-g7c22