FIX: Deleting selected wasn't marking them as deleted

This commit is contained in:
Robin Ward 2016-02-16 14:27:41 -05:00
parent 5d9278c098
commit ba203b3a94

View File

@ -386,27 +386,26 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
}, },
deleteSelected() { deleteSelected() {
const self = this; bootbox.confirm(I18n.t("post.delete.confirm", { count: this.get('selectedPostsCount')}), result => {
bootbox.confirm(I18n.t("post.delete.confirm", { count: this.get('selectedPostsCount')}), function(result) {
if (result) { if (result) {
// If all posts are selected, it's the same thing as deleting the topic // If all posts are selected, it's the same thing as deleting the topic
if (self.get('allPostsSelected')) { if (this.get('allPostsSelected')) {
return self.deleteTopic(); return this.deleteTopic();
} }
const selectedPosts = self.get('selectedPosts'), const selectedPosts = this.get('selectedPosts');
selectedReplies = self.get('selectedReplies'), const selectedReplies = this.get('selectedReplies');
postStream = self.get('model.postStream'), const postStream = this.get('model.postStream');
toRemove = [];
Discourse.Post.deleteMany(selectedPosts, selectedReplies); Discourse.Post.deleteMany(selectedPosts, selectedReplies);
postStream.get('posts').forEach(function (p) { postStream.get('posts').forEach(p => {
if (self.postSelected(p)) { toRemove.addObject(p); } if (this.postSelected(p)) {
p.set('deleted_at', new Date());
}
}); });
postStream.removePosts(toRemove); this.send('toggleMultiSelect');
self.send('toggleMultiSelect');
} }
}); });
}, },