Skip to content

Commit

Permalink
Fixing broken remove from collection code
Browse files Browse the repository at this point in the history
  • Loading branch information
willdoran committed Oct 5, 2016
1 parent 9637ea7 commit 5cf87c4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/main/posts/collections/listing.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ function CollectionListingController(
// Remove post(s) from a given collection
function removeFromCollection(selectedCollection) {
var collectionId = selectedCollection.id, collection = selectedCollection.name;

CollectionEndpoint.removePost({'collectionId': collectionId, 'id': $scope.post.id})
.$promise
var calls = [];
_.each($scope.posts, function (post) {
calls.push(
CollectionEndpoint.removePost({'collectionId': collectionId, 'id': post.id})
);
});
$q.all(calls)
.then(function () {
$scope.post.sets = _.without($scope.post.sets, String(collectionId));
_.each($scope.posts, function (post) {
post.sets = _.without($scope.post.sets, String(collectionId));
});
Notify.notify('notify.collection.removed_from_collection', {collection: collection});
}, function (errorResponse) {
Notify.apiErrors(errorResponse);
Expand Down

0 comments on commit 5cf87c4

Please sign in to comment.