Add appstore accessToken to subscription setup links
This commit is contained in:
@@ -14,8 +14,6 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
$scope.notifications = [];
|
||||
$scope.hideNavBarActions = $location.path() === '/logs';
|
||||
|
||||
var waitingForPlanSelection = false;
|
||||
|
||||
$scope.isActive = function (url) {
|
||||
if (!$route.current) return false;
|
||||
return $route.current.$$route.originalPath.indexOf(url) === 0;
|
||||
@@ -27,35 +25,8 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
Client.logout();
|
||||
};
|
||||
|
||||
// NOTE: this function is exported and called from the settings.js
|
||||
$scope.pollSubscriptionStatus = function () {
|
||||
if (waitingForPlanSelection) return; // prevent double polling
|
||||
waitingForPlanSelection = true;
|
||||
|
||||
function checkPlan() {
|
||||
if (!waitingForPlanSelection) return;
|
||||
|
||||
Client.getSubscription(function (error, subscription) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
// check again to give more immediate feedback once a subscription was setup
|
||||
if (subscription.plan.id === 'free' || subscription.plan.id === 'expired') {
|
||||
$timeout(checkPlan, 5000);
|
||||
} else {
|
||||
waitingForPlanSelection = false;
|
||||
$scope.subscription = subscription;
|
||||
|
||||
// check for updates to stay in sync
|
||||
Client.checkForUpdates(function (error) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
Client.refreshConfig();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
checkPlan();
|
||||
$scope.openSubscriptionSetup = function () {
|
||||
Client.openSubscriptionSetup($scope.subscription);
|
||||
};
|
||||
|
||||
// NOTE: this function is exported and called from the appstore.js
|
||||
@@ -64,7 +35,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
|
||||
Client.getSubscription(function (error, subscription) {
|
||||
if (error && error.statusCode === 412) return; // ignore if not yet registered
|
||||
if (error) console.error(error);
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.subscription = subscription;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user