Use new subscription API in settings controller
This commit is contained in:
@@ -9,7 +9,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
$scope.client = Client;
|
||||
$scope.user = Client.getUserInfo();
|
||||
$scope.config = Client.getConfig();
|
||||
$scope.appstoreConfig = {};
|
||||
$scope.installedApps = Client.getInstalledApps();
|
||||
|
||||
$scope.subscription = null;
|
||||
@@ -308,14 +307,14 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
}
|
||||
|
||||
function getSubscription() {
|
||||
AppStore.getSubscription($scope.appstoreConfig, function (error, result) {
|
||||
Client.getSubscription(function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
if (!$scope.$parent) return; // user changed view. otherwise we get an error that $scope.$parent is null
|
||||
|
||||
$scope.subscription = result;
|
||||
|
||||
// also reload the subscription on the main controller
|
||||
$scope.$parent.fetchAppstoreProfileAndSubscription(function () {});
|
||||
$scope.$parent.updateSubscriptionStatus(function () {});
|
||||
|
||||
// check again to give more immediate feedback once a subscription was setup
|
||||
if (result.plan.id === 'free') $timeout(getSubscription, 10000);
|
||||
@@ -418,20 +417,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
$scope.update.checkStatus();
|
||||
|
||||
if (!$scope.config.managed) {
|
||||
Client.getAppstoreConfig(function (error, appstoreConfig) {
|
||||
if (error) return console.error(error);
|
||||
if (!appstoreConfig.token) return;
|
||||
|
||||
AppStore.getProfile(appstoreConfig.token, function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
// assign late to avoid UI flicketing on update
|
||||
appstoreConfig.profile = result;
|
||||
$scope.appstoreConfig = appstoreConfig;
|
||||
|
||||
getSubscription();
|
||||
});
|
||||
});
|
||||
getSubscription();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user