diff --git a/src/js/controllers/disclaimer.js b/src/js/controllers/disclaimer.js index 853b496be..ec9b6ba65 100644 --- a/src/js/controllers/disclaimer.js +++ b/src/js/controllers/disclaimer.js @@ -3,10 +3,13 @@ angular.module('copayApp.controllers').controller('disclaimerController', function($scope, $timeout, $log, profileService, isCordova, storageService, applicationService, gettextCatalog, uxLanguage, go) { self = this; + self.tries = 0; - var create = function() { + var create = function(noWallet) { $scope.creatingProfile = true; - profileService.create({}, function(err) { + profileService.create({ + noWallet: noWallet + }, function(err) { if (err) { $log.warn(err); @@ -14,7 +17,13 @@ angular.module('copayApp.controllers').controller('disclaimerController', $scope.$apply(); $timeout(function() { $log.warn('Retrying to create profile......'); - create(); + if (self.tries == 3) { + self.tries == 0; + create(true); + } else { + self.tries += 1; + create(false); + } }, 3000); } else { $scope.error = ""; @@ -26,7 +35,7 @@ angular.module('copayApp.controllers').controller('disclaimerController', this.init = function() { self.lang = uxLanguage.currentLanguage; storageService.getProfile(function(err, profile) { - if (!profile) create(); + if (!profile) create(false); else $scope.creatingProfile = false; //compatible diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 669f4d67c..ad17c45bd 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -154,7 +154,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.disclaimerAccepted = true; profileService.setDisclaimerAccepted(function(err) { if (err) $log.error(err); - go.walletHome(); + if (lodash.isEmpty(profileService.focusedClient)) { + $rootScope.$emit('Local/NoWallets'); + } else go.walletHome(); }); }; @@ -1357,12 +1359,16 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); $rootScope.$on('Local/NoWallets', function(event) { - $timeout(function() { - self.hasProfile = true; - self.noFocusedWallet = true; - self.isComplete = null; - self.walletName = null; - go.path('import'); + profileService.isDisclaimerAccepted(function(v) { + if (v) { + $timeout(function() { + self.hasProfile = true; + self.noFocusedWallet = true; + self.isComplete = null; + self.walletName = null; + go.path('import'); + }); + } }); });