Skip to content

Commit

Permalink
listen for "editors.documentType.saved" instead of "editors.content.r…
Browse files Browse the repository at this point in the history
…eload"
  • Loading branch information
nielslyngsoe committed Mar 22, 2019
1 parent da503cc commit d806855
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,24 @@
function isContentCultureVariant() {
return $scope.content.variants.length > 1;
}

function reload() {
$scope.page.loading = true;
loadContent().then(function() {
$scope.page.loading = false;
});
}

function bindEvents() {
//bindEvents can be called more than once and we don't want to have multiple bound events
for (var e in evts) {
eventsService.unsubscribe(evts[e]);
}

evts.push(eventsService.on("editors.content.reload", function (name, args) {
evts.push(eventsService.on("editors.documentType.saved", function (name, args) {
// if this content item uses the updated doc type we need to reload the content item
if(args && args.node && args.node.key === $scope.content.key) {
$scope.page.loading = true;
loadContent().then(function() {
$scope.page.loading = false;
});
if(args && args.documentType && $scope.content.documentType.id === args.documentType.id) {
reload();
}
}));

Expand Down

0 comments on commit d806855

Please sign in to comment.