2015-08-27 11:24:39 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('disclaimerController',
|
2015-11-24 17:16:52 -03:00
|
|
|
function($scope, $timeout, $log, profileService, isCordova, storageService, applicationService, gettextCatalog, uxLanguage, go) {
|
2015-11-17 12:39:51 -03:00
|
|
|
self = this;
|
2015-12-14 14:02:27 -03:00
|
|
|
self.tries = 0;
|
2015-11-30 12:58:52 -03:00
|
|
|
|
2015-12-14 14:02:27 -03:00
|
|
|
var create = function(noWallet) {
|
2015-11-17 13:36:31 -03:00
|
|
|
$scope.creatingProfile = true;
|
2015-12-14 14:02:27 -03:00
|
|
|
profileService.create({
|
|
|
|
|
noWallet: noWallet
|
|
|
|
|
}, function(err) {
|
2015-11-17 13:36:31 -03:00
|
|
|
|
|
|
|
|
if (err) {
|
2015-11-24 17:16:52 -03:00
|
|
|
$log.warn(err);
|
2015-11-30 13:32:54 -03:00
|
|
|
$scope.error = err;
|
|
|
|
|
$scope.$apply();
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$log.warn('Retrying to create profile......');
|
2015-12-14 14:02:27 -03:00
|
|
|
if (self.tries == 3) {
|
|
|
|
|
self.tries == 0;
|
|
|
|
|
create(true);
|
|
|
|
|
} else {
|
|
|
|
|
self.tries += 1;
|
|
|
|
|
create(false);
|
|
|
|
|
}
|
2015-11-30 13:32:54 -03:00
|
|
|
}, 3000);
|
2015-11-17 13:36:31 -03:00
|
|
|
} else {
|
|
|
|
|
$scope.error = "";
|
|
|
|
|
$scope.creatingProfile = false;
|
|
|
|
|
}
|
2015-09-16 02:20:45 +02:00
|
|
|
});
|
|
|
|
|
};
|
2015-11-17 11:10:09 -03:00
|
|
|
|
2015-12-04 18:45:35 -03:00
|
|
|
this.init = function() {
|
|
|
|
|
self.lang = uxLanguage.currentLanguage;
|
|
|
|
|
storageService.getProfile(function(err, profile) {
|
2015-12-14 14:02:27 -03:00
|
|
|
if (!profile) create(false);
|
2015-12-04 18:45:35 -03:00
|
|
|
else $scope.creatingProfile = false;
|
2015-11-30 12:58:52 -03:00
|
|
|
|
2015-12-04 18:45:35 -03:00
|
|
|
//compatible
|
2015-12-07 12:52:42 -03:00
|
|
|
profileService.isDisclaimerAccepted(function(val) {
|
2015-12-04 18:45:35 -03:00
|
|
|
if (val) go.walletHome();
|
|
|
|
|
});
|
2015-11-30 16:34:24 -03:00
|
|
|
});
|
2015-12-04 18:45:35 -03:00
|
|
|
};
|
2015-08-27 11:24:39 -03:00
|
|
|
});
|