create profile before accepting terms

This commit is contained in:
Gabriel Bazán 2015-11-17 11:10:09 -03:00
commit 8217c7bfbd
2 changed files with 35 additions and 41 deletions

View file

@ -1,47 +1,39 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('disclaimerController', angular.module('copayApp.controllers').controller('disclaimerController',
function($scope, $timeout, $log, profileService, isCordova, storageService, gettextCatalog, uxLanguage, go) { function($scope, $timeout, $log, profileService, isCordova, storageService, gettextCatalog, applicationService, uxLanguage, go) {
$scope.create = function(noWallet) {
$scope.create = function() {
$scope.creatingProfile = true; $scope.creatingProfile = true;
if (isCordova) { if (isCordova) {
window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Loading...'), true); window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Loading...'), true);
} }
$scope.loading = true; $scope.loading = true;
$timeout(function() {
storageService.setCopayDisclaimerFlag(function(err) { storageService.setCopayDisclaimerFlag(function(err) {
$scope.creatingProfile = false;
if (isCordova) { if (isCordova) {
window.plugins.spinnerDialog.hide(); window.plugins.spinnerDialog.hide();
} }
profileService.create({ applicationService.restart();
noWallet: noWallet
}, function(err) {
if (err) {
$scope.creatingProfile = false;
$log.warn(err);
$scope.error = err;
$scope.$apply();
$timeout(function() {
$scope.create(noWallet);
}, 3000);
}
}); });
});
}, 100);
}; };
$scope.init = function() { $scope.init = function(noWallet) {
storageService.getCopayDisclaimerFlag(function(err, val) { storageService.getCopayDisclaimerFlag(function(err, val) {
$scope.lang = uxLanguage.currentLanguage; $scope.lang = uxLanguage.currentLanguage;
$scope.agreed = val; $scope.agreed = val;
if (profileService.profile) { profileService.create({
go.walletHome(); noWallet: noWallet
}, function(err) {
if (err) {
$log.warn(err);
$scope.error = err;
$scope.$apply();
} }
$timeout(function() { });
$scope.$digest();
}, 1);
}); });
}; };
}); });

View file

@ -1295,7 +1295,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on('Local/NewFocusedWallet', function() { $rootScope.$on('Local/NewFocusedWallet', function() {
self.setFocusedWallet(); self.setFocusedWallet();
self.updateTxHistory(); self.updateTxHistory();
go.walletHome(); storageService.getCopayDisclaimerFlag(function(err, val) {
if (val) go.walletHome();
storageService.getCleanAndScanAddresses(function(err, walletId) { storageService.getCleanAndScanAddresses(function(err, walletId) {
if (walletId && profileService.walletClients[walletId]) { if (walletId && profileService.walletClients[walletId]) {
$log.debug('Clear last address cache and Scan ', walletId); $log.debug('Clear last address cache and Scan ', walletId);
@ -1306,6 +1307,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
} }
}); });
}); });
});
$rootScope.$on('Local/SetTab', function(event, tab, reset) { $rootScope.$on('Local/SetTab', function(event, tab, reset) {
self.setTab(tab, reset); self.setTab(tab, reset);