diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-07-05 16:20:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-05 16:20:25 -0400 |
commit | 4efb0f37b701aa8e875e541cc4f121c264e4d8ab (patch) | |
tree | 420035ccd95bf8e3d4c1b0d457e74a37db52eb8a /webapp | |
parent | dd78a3f1fa416cc9b16bf8d4b80b5f9bb10c528a (diff) | |
download | chat-4efb0f37b701aa8e875e541cc4f121c264e4d8ab.tar.gz chat-4efb0f37b701aa8e875e541cc4f121c264e4d8ab.tar.bz2 chat-4efb0f37b701aa8e875e541cc4f121c264e4d8ab.zip |
Increase post visibility in current channel when receiving posts (#6848)
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/actions/post_actions.jsx | 36 |
1 files 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: { |