diff --git a/dashboard/src/js/main.js b/dashboard/src/js/main.js index b3c1485c2..3003f2cf2 100644 --- a/dashboard/src/js/main.js +++ b/dashboard/src/js/main.js @@ -97,19 +97,24 @@ angular.module('Application').controller('MainController', ['$scope', '$route', } $scope.fetchAppstoreProfileAndSubscription = function (callback) { - if (!$scope.appstoreConfig.token) return callback(); - - AppStore.getProfile($scope.appstoreConfig.token, function (error, result) { + Client.getAppstoreConfig(function (error, result) { if (error) return callback(error); + if (!result.token) return callback(); - $scope.appstoreConfig.profile = result; + $scope.appstoreConfig = result; - AppStore.getSubscription($scope.appstoreConfig, function (error, result) { + AppStore.getProfile($scope.appstoreConfig.token, function (error, result) { if (error) return callback(error); - $scope.subscription = result; + $scope.appstoreConfig.profile = result; - callback(); + AppStore.getSubscription($scope.appstoreConfig, function (error, result) { + if (error) return callback(error); + + $scope.subscription = result; + + callback(); + }); }); }); }; @@ -166,17 +171,10 @@ angular.module('Application').controller('MainController', ['$scope', '$route', if ($scope.user.admin) { runConfigurationChecks(); - Client.getAppstoreConfig(function (error, result) { - if (error) return console.error(error); - if (!result.token) return; + $scope.fetchAppstoreProfileAndSubscription(function (error) { + if (error) console.error(error); - $scope.appstoreConfig = result; - - $scope.fetchAppstoreProfileAndSubscription(function (error) { - if (error) console.error(error); - - $scope.ready = true; - }); + $scope.ready = true; }); } }); diff --git a/dashboard/src/views/appstore.js b/dashboard/src/views/appstore.js index f189a8694..54d7b20d7 100644 --- a/dashboard/src/views/appstore.js +++ b/dashboard/src/views/appstore.js @@ -275,7 +275,6 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca fetchAppstoreConfig(function (error) { if (error) return console.error('Unable to fetch appstore config.', error); - $scope.$parent.fetchAppstoreProfileAndSubscription(function () {}); }); }); }); @@ -485,6 +484,11 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca // clear busy state when a login/signup was performed $scope.appstoreLogin.busy = false; + // also update the root controller status + $scope.$parent.fetchAppstoreProfileAndSubscription(function (error) { + if (error) console.error(error); + }); + callback(); }); });