Merge "Allow the Subscribe directive to work without a list of subscriptions"

This commit is contained in:
Jenkins 2016-06-14 13:47:31 +00:00 committed by Gerrit Code Review
commit b61fbb908b
3 changed files with 15 additions and 26 deletions

View File

@ -21,8 +21,7 @@ angular.module('sb.story').controller('StoryDetailController',
function ($log, $rootScope, $scope, $state, $stateParams, $modal, Session,
Preference, TimelineEvent, Comment, TimelineEventTypes, story,
Story, creator, tasks, Task, DSCacheFactory, User, $q,
storyboardApiBase, SubscriptionList, CurrentUser,
SessionModalService, moment, $document) {
storyboardApiBase, SessionModalService, moment, $document) {
'use strict';
var pageSize = Preference.get('story_detail_page_size');
@ -510,12 +509,4 @@ angular.module('sb.story').controller('StoryDetailController',
},
handleServiceError);
};
//GET subscriptions
var cuPromise = CurrentUser.resolve();
cuPromise.then(function(user){
$scope.storySubscriptions = SubscriptionList.subsList(
'story', user);
});
});

View File

@ -56,8 +56,7 @@
<i class="fa fa-pencil"></i>
</a>
<subscribe resource="story"
resource-id="story.id"
subscriptions="storySubscriptions">
resource-id="story.id">
</subscribe>
<button type="button"
class="btn btn-link"

View File

@ -188,23 +188,22 @@ angular.module('sb.util').directive('subscribe',
$scope.resolving = true;
cuPromise.then(
function () {
angular.forEach($scope.subscriptions,
function(subscription) {
if ($scope.resourceId ===
subscription.target_id) {
setSubscription(subscription);
}
}
);
$scope.resolving = false;
}
);
cuPromise.then(function () {
angular.forEach($scope.subscriptions, function(sub) {
if ($scope.resourceId === sub.target_id) {
setSubscription(sub);
}
});
$scope.resolving = false;
});
}
// On initialization, resolve.
$scope.subscriptions.$promise.then(resolveSubsList);
if (!!$scope.subscriptions) {
$scope.subscriptions.$promise.then(resolveSubsList);
} else {
resolveSubscription();
}
}
};
});