add disclaimer controller test
This commit is contained in:
parent
229802f0ca
commit
7781b93a88
5 changed files with 122 additions and 22 deletions
|
|
@ -4,45 +4,53 @@ angular.module('copayApp.controllers').controller('disclaimerController',
|
|||
function($scope, $timeout, $log, $ionicSideMenuDelegate, profileService, applicationService, gettextCatalog, uxLanguage, go) {
|
||||
var self = this;
|
||||
self.tries = 0;
|
||||
$scope.creatingProfile = true;
|
||||
self.creatingProfile = true;
|
||||
|
||||
var create = function(noWallet) {
|
||||
profileService.create({
|
||||
noWallet: noWallet
|
||||
}, function(err) {
|
||||
var create = function(opts) {
|
||||
opts = opts || {};
|
||||
$log.debug('Creating profile');
|
||||
profileService.create(opts, function(err) {
|
||||
|
||||
console.log('[disclaimer.js.13]', err); //TODO
|
||||
if (err) {
|
||||
$log.warn(err);
|
||||
$scope.error = err;
|
||||
$scope.$apply();
|
||||
$timeout(function() {
|
||||
|
||||
return $timeout(function() {
|
||||
$log.warn('Retrying to create profile......');
|
||||
if (self.tries == 3) {
|
||||
self.tries == 0;
|
||||
create(true);
|
||||
return create({
|
||||
noWallet: true
|
||||
});
|
||||
} else {
|
||||
self.tries += 1;
|
||||
create(false);
|
||||
return create();
|
||||
}
|
||||
}, 3000);
|
||||
} else {
|
||||
$scope.error = "";
|
||||
$scope.creatingProfile = false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.error = "";
|
||||
self.creatingProfile = false;
|
||||
|
||||
console.log('[disclaimer.js.33]'); //TODO
|
||||
});
|
||||
};
|
||||
|
||||
this.init = function() {
|
||||
|
||||
this.init = function(opts) {
|
||||
$ionicSideMenuDelegate.canDragContent(false);
|
||||
self.lang = uxLanguage.currentLanguage;
|
||||
|
||||
profileService.getProfile(function(err, profile) {
|
||||
if (!profile) {
|
||||
create(false);
|
||||
|
||||
console.log('[disclaimer.js.43]'); //TODO
|
||||
create(opts);
|
||||
console.log('[disclaimer.js.46]'); //TODO
|
||||
} else {
|
||||
$log.debug('There is a profile already');
|
||||
$scope.creatingProfile = false;
|
||||
$log.info('There is already a profile');
|
||||
self.creatingProfile = false;
|
||||
profileService.bindProfile(profile, function(err) {
|
||||
if (!err || !err.message || !err.message.match('NONAGREEDDISCLAIMER')) {
|
||||
$log.debug('Disclaimer already accepted at #disclaimer. Redirect to Wallet Home.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue