From b9f5728ab74412e2e2dc947141324f40b62fb9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Tue, 11 Oct 2016 12:22:58 -0300 Subject: [PATCH] if no wallet resume welcome - if no disclaimer accepted resume disclaimer --- src/js/routes.js | 40 +++++++++++++------------------ src/js/services/storageService.js | 14 +++-------- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/src/js/routes.js b/src/js/routes.js index e75079d2b..cf42d5bfa 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -840,13 +840,13 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) - /* - * - * BitPay Card - * - */ + /* + * + * BitPay Card + * + */ - .state('tabs.bitpayCard', { + .state('tabs.bitpayCard', { url: '/bitpay-card', views: { 'tab-home@tabs': { @@ -973,21 +973,19 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr $log.debug('No profile... redirecting'); $state.go('onboarding.welcome'); } else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) { - $log.debug('Display disclaimer... redirecting'); - storageService.getLastState(function(err, state) { - if (err && !state) { - $log.error(err); - $state.go('onboarding.disclaimer'); - } - else { - var state = JSON.parse(state); - $state.go(state.name, state.toParams); - } - }) + if (lodash.isEmpty(profileService.getWallets())) { + $log.debug('No wallets and no disclaimer... redirecting'); + $state.go('onboarding.welcome'); + } + else { + $log.debug('Display disclaimer... redirecting'); + $state.go('onboarding.disclaimer'); + } } else { throw new Error(err); // TODO } - } else { + } + else { profileService.storeProfileIfDirty(); $log.debug('Profile loaded ... Starting UX.'); scannerService.gentleInitialize(); @@ -1014,11 +1012,5 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr $log.debug('Route change from:', fromState.name || '-', ' to:', toState.name); $log.debug(' toParams:' + JSON.stringify(toParams || {})); $log.debug(' fromParams:' + JSON.stringify(fromParams || {})); - - if (!toState.name.match(/onboarding/)) return; - var state = {}; - state.name = toState.name; - state.toParams = toParams; - if (state.name != 'starting') storageService.setLastState(JSON.stringify(state), function() {}); }); }); diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index f9f14fdf7..a0e0f6503 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -199,9 +199,9 @@ angular.module('copayApp.services') storage.get('homeTip', cb); }; - root.setHomeTipAccepted = function(val, cb) { - storage.set('homeTip', val, cb); - }; + root.setHomeTipAccepted = function(val, cb) { + storage.set('homeTip', val, cb); + }; root.setHideBalanceFlag = function(walletId, val, cb) { storage.set('hideBalance-' + walletId, val, cb); @@ -284,14 +284,6 @@ angular.module('copayApp.services') storage.remove('nextStep-' + service, cb); }; - root.setLastState = function(state, toParams, cb) { - storage.set('lastState', state, toParams, cb); - }; - - root.getLastState = function(cb) { - storage.get('lastState', cb); - }; - root.checkQuota = function() { var block = ''; // 50MB