diff options
Diffstat (limited to 'web/react/stores/post_store.jsx')
-rw-r--r-- | web/react/stores/post_store.jsx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx index 5100a4936..a6dfcd46f 100644 --- a/web/react/stores/post_store.jsx +++ b/web/react/stores/post_store.jsx @@ -265,6 +265,12 @@ class PostStoreClass extends EventEmitter { } deletePost(post) { + const postInfo = this.postsInfo[post.channel_id]; + if (!postInfo) { + // the post that has been deleted is in a channel that we haven't seen so just ignore it + return; + } + const postList = this.postsInfo[post.channel_id].postList; if (isPostListNull(postList)) { @@ -297,6 +303,20 @@ class PostStoreClass extends EventEmitter { postList.order.splice(index, 1); } + for (const pid in postList.posts) { + if (!postList.posts.hasOwnProperty(pid)) { + continue; + } + + if (postList.posts[pid].root_id === post.id) { + Reflect.deleteProperty(postList.posts, pid); + const commentIndex = postList.order.indexOf(pid); + if (commentIndex !== -1) { + postList.order.splice(commentIndex, 1); + } + } + } + this.postsInfo[channelId].postList = postList; } |