From a25ae8fed2b72f88b6ba5a9a0a6110fab085470c Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 14 Nov 2016 07:38:05 -0500 Subject: Off screen edited posts no longer show up as new posts (#4485) --- webapp/actions/websocket_actions.jsx | 2 +- webapp/stores/post_store.jsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx index 36c6cbdc9..8632f4135 100644 --- a/webapp/actions/websocket_actions.jsx +++ b/webapp/actions/websocket_actions.jsx @@ -180,7 +180,7 @@ function handleNewPostEvent(msg) { function handlePostEditEvent(msg) { // Store post const post = JSON.parse(msg.data.post); - PostStore.storePost(post); + PostStore.storePost(post, false); PostStore.emitChange(); // Update channel state diff --git a/webapp/stores/post_store.jsx b/webapp/stores/post_store.jsx index a4e49fc98..fbe5cd457 100644 --- a/webapp/stores/post_store.jsx +++ b/webapp/stores/post_store.jsx @@ -245,7 +245,7 @@ class PostStoreClass extends EventEmitter { this.postsInfo[id].postList = combinedPosts; } - storePost(post) { + storePost(post, isNewPost = false) { const postList = makePostListNonNull(this.getAllPosts(post.channel_id)); if (post.pending_post_id !== '') { @@ -255,7 +255,7 @@ class PostStoreClass extends EventEmitter { post.pending_post_id = ''; postList.posts[post.id] = post; - if (postList.order.indexOf(post.id) === -1) { + if (isNewPost && postList.order.indexOf(post.id) === -1) { postList.order.unshift(post.id); } @@ -629,7 +629,7 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => { PostStore.emitChange(); break; case ActionTypes.RECEIVED_POST: - PostStore.storePost(action.post); + PostStore.storePost(action.post, true); PostStore.emitChange(); break; case ActionTypes.RECEIVED_EDIT_POST: -- cgit v1.2.3-1-g7c22