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.