From 8217c7bfbd4146c7d30ff68cd851605d384c862c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Tue, 17 Nov 2015 11:10:09 -0300 Subject: [PATCH] create profile before accepting terms --- src/js/controllers/disclaimer.js | 50 ++++++++++++++------------------ src/js/controllers/index.js | 26 +++++++++-------- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/src/js/controllers/disclaimer.js b/src/js/controllers/disclaimer.js index f1cedcc71..0ad075bca 100644 --- a/src/js/controllers/disclaimer.js +++ b/src/js/controllers/disclaimer.js @@ -1,47 +1,39 @@ 'use strict'; 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; if (isCordova) { window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Loading...'), true); } $scope.loading = true; - $timeout(function() { - storageService.setCopayDisclaimerFlag(function(err) { - if (isCordova) { - window.plugins.spinnerDialog.hide(); - } - profileService.create({ - noWallet: noWallet - }, function(err) { - if (err) { - $scope.creatingProfile = false; - $log.warn(err); - $scope.error = err; - $scope.$apply(); - $timeout(function() { - $scope.create(noWallet); - }, 3000); - } - }); - }); - }, 100); + storageService.setCopayDisclaimerFlag(function(err) { + $scope.creatingProfile = false; + if (isCordova) { + window.plugins.spinnerDialog.hide(); + } + applicationService.restart(); + }); }; - $scope.init = function() { + $scope.init = function(noWallet) { storageService.getCopayDisclaimerFlag(function(err, val) { $scope.lang = uxLanguage.currentLanguage; $scope.agreed = val; - if (profileService.profile) { - go.walletHome(); - } - $timeout(function() { - $scope.$digest(); - }, 1); + profileService.create({ + noWallet: noWallet + }, function(err) { + if (err) { + $log.warn(err); + $scope.error = err; + $scope.$apply(); + } + }); }); }; + }); diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 3dcedc4ae..dd359e663 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -142,7 +142,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r var defaults = configService.getDefaults(); var config = configService.getSync(); - self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url); + self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url); }; self.setTab = function(tab, reset, tries, switchState) { @@ -807,7 +807,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r return i_cb(null, newTxs); } - if (walletId == profileService.focusedClient.credentials.walletId) + if (walletId == profileService.focusedClient.credentials.walletId) self.txProgress = newTxs.length; $timeout(function() { @@ -822,7 +822,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r var newHistory = lodash.compact(txs.concat(txsFromLocal)); $log.debug('Tx History synced. Total Txs: ' + newHistory.length); - if (walletId == profileService.focusedClient.credentials.walletId) { + if (walletId == profileService.focusedClient.credentials.walletId) { self.completeHistory = newHistory; self.txHistory = newHistory.slice(0, self.historyShowLimit); self.historyShowShowAll = newHistory.length >= self.historyShowLimit; @@ -1295,15 +1295,17 @@ angular.module('copayApp.controllers').controller('indexController', function($r $rootScope.$on('Local/NewFocusedWallet', function() { self.setFocusedWallet(); self.updateTxHistory(); - go.walletHome(); - storageService.getCleanAndScanAddresses(function(err, walletId) { - if (walletId && profileService.walletClients[walletId]) { - $log.debug('Clear last address cache and Scan ', walletId); - addressService.expireAddress(walletId, function(err) { - self.startScan(walletId); - }); - storageService.removeCleanAndScanAddresses(function() {}); - } + storageService.getCopayDisclaimerFlag(function(err, val) { + if (val) go.walletHome(); + storageService.getCleanAndScanAddresses(function(err, walletId) { + if (walletId && profileService.walletClients[walletId]) { + $log.debug('Clear last address cache and Scan ', walletId); + addressService.expireAddress(walletId, function(err) { + self.startScan(walletId); + }); + storageService.removeCleanAndScanAddresses(function() {}); + } + }); }); });