From aa31f3081abc86fbe975b18a8ac7c930a23b3a5e Mon Sep 17 00:00:00 2001
From: Robin Ward <robin.ward@gmail.com>
Date: Thu, 11 Feb 2016 16:45:28 -0500
Subject: [PATCH] FIX: Placeholders should not show up to non-admins when
 deleting posts

---
 .../discourse/lib/posts-with-placeholders.js.es6    |  5 +++++
 .../javascripts/discourse/models/post-stream.js.es6 | 13 ++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/app/assets/javascripts/discourse/lib/posts-with-placeholders.js.es6 b/app/assets/javascripts/discourse/lib/posts-with-placeholders.js.es6
index d6d62ee1d..a57f46c9e 100644
--- a/app/assets/javascripts/discourse/lib/posts-with-placeholders.js.es6
+++ b/app/assets/javascripts/discourse/lib/posts-with-placeholders.js.es6
@@ -36,6 +36,11 @@ export default Ember.Object.extend(Ember.Array, {
     this._changeArray(cb, this.get('posts.length') - 1, 1, 0);
   },
 
+  refreshAll(cb) {
+    const length = this.get('posts.length');
+    this._changeArray(cb, 0, length, length);
+  },
+
   appending(postIds) {
     this._changeArray(() => {
       const appendingIds = this._appendingIds;
diff --git a/app/assets/javascripts/discourse/models/post-stream.js.es6 b/app/assets/javascripts/discourse/models/post-stream.js.es6
index b1a311bc8..effe485cc 100644
--- a/app/assets/javascripts/discourse/models/post-stream.js.es6
+++ b/app/assets/javascripts/discourse/models/post-stream.js.es6
@@ -429,12 +429,15 @@ export default RestModel.extend({
   removePosts(posts) {
     if (Ember.isEmpty(posts)) { return; }
 
-    const postIds = posts.map(p => p.get('id'));
-    const identityMap = this._identityMap;
+    this.get('postsWithPlaceholders').refreshAll(() => {
+      const allPosts = this.get('posts');
+      const postIds = posts.map(p => p.get('id'));
+      const identityMap = this._identityMap;
 
-    this.get('stream').removeObjects(postIds);
-    this.get('posts').removeObjects(posts);
-    postIds.forEach(id => delete identityMap[id]);
+      this.get('stream').removeObjects(postIds);
+      allPosts.removeObjects(posts);
+      postIds.forEach(id => delete identityMap[id]);
+    });
   },
 
   // Returns a post from the identity map if it's been inserted.