diff --git a/src/js/routes.js b/src/js/routes.js index e37d8efa2..d7b78544f 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -726,7 +726,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }); }) - .run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService) { + .run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService) { uxLanguage.init(); openURLService.init(); @@ -782,10 +782,19 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr if (err) { if (err.message && err.message.match('NOPROFILE')) { $log.debug('No profile... redirecting'); - $state.transitionTo('onboarding.welcome'); + $state.go('onboarding.welcome'); } else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) { $log.debug('Display disclaimer... redirecting'); - $state.transitionTo('onboarding.disclaimer'); + 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); + } + }) } else { throw new Error(err); // TODO } @@ -793,7 +802,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr profileService.storeProfileIfDirty(); $log.debug('Profile loaded ... Starting UX.'); - $state.transitionTo('tabs.home'); + $state.go('tabs.home'); } }); }); @@ -816,6 +825,9 @@ 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 || {})); - + var state = {}; + state.name = toState.name; + state.toParams = toParams; + storageService.setLastState(JSON.stringify(state), function() {}); }); }); diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index a498dfb89..706e59d4f 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -276,6 +276,13 @@ 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 = '';