poll subscription status only when button got clicked
otherwise, both stripe, our appstore db is bombarded
This commit is contained in:
@@ -314,6 +314,15 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
Client.getSubscription(function (error, result) {
|
||||
$scope.subscriptionBusy = false;
|
||||
|
||||
if (error && error.statusCode === 412) return; // not yet registered
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.subscription = result;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.pollSubscriptionStatus = function () {
|
||||
Client.getSubscription(function (error, result) {
|
||||
if (error && error.statusCode === 412) return; // not yet registered
|
||||
if (error) return console.error(error);
|
||||
if (!$scope.$parent) return; // user changed view. otherwise we get an error that $scope.$parent is null
|
||||
@@ -323,10 +332,9 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
// also reload the subscription on the main controller
|
||||
$scope.$parent.updateSubscriptionStatus();
|
||||
|
||||
// check again to give more immediate feedback once a subscription was setup
|
||||
if (result.plan.id === 'free') $timeout(getSubscription, 10000);
|
||||
$timeout($scope.pollSubscriptionStatus, 10 * 1000);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$('#avatarFileInput').get(0).onchange = function (event) {
|
||||
var fr = new FileReader();
|
||||
|
||||
Reference in New Issue
Block a user