FIX: Placeholders should not show up to non-admins when deleting posts

This commit is contained in:
Robin Ward 2016-02-11 16:45:28 -05:00
parent 4e209846cb
commit aa31f3081a
2 changed files with 13 additions and 5 deletions

View File

@ -36,6 +36,11 @@ export default Ember.Object.extend(Ember.Array, {
this._changeArray(cb, this.get('posts.length') - 1, 1, 0); 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) { appending(postIds) {
this._changeArray(() => { this._changeArray(() => {
const appendingIds = this._appendingIds; const appendingIds = this._appendingIds;

View File

@ -429,12 +429,15 @@ export default RestModel.extend({
removePosts(posts) { removePosts(posts) {
if (Ember.isEmpty(posts)) { return; } if (Ember.isEmpty(posts)) { return; }
const postIds = posts.map(p => p.get('id')); this.get('postsWithPlaceholders').refreshAll(() => {
const identityMap = this._identityMap; const allPosts = this.get('posts');
const postIds = posts.map(p => p.get('id'));
const identityMap = this._identityMap;
this.get('stream').removeObjects(postIds); this.get('stream').removeObjects(postIds);
this.get('posts').removeObjects(posts); allPosts.removeObjects(posts);
postIds.forEach(id => delete identityMap[id]); postIds.forEach(id => delete identityMap[id]);
});
}, },
// Returns a post from the identity map if it's been inserted. // Returns a post from the identity map if it's been inserted.