From 984a7a66510a5bd39a01bba9de2823abef5daa34 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sat, 6 Dec 2014 21:07:26 -0300 Subject: [PATCH] fix reload in cordova --- js/controllers/createProfile.js | 2 ++ js/controllers/head.js | 1 - js/controllers/home.js | 2 +- js/controllers/sidebar.js | 1 - js/services/applicationService.js | 28 +++++++++++++++++----------- js/services/identityService.js | 2 ++ 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/js/controllers/createProfile.js b/js/controllers/createProfile.js index c3a7900eb..bd857cd46 100644 --- a/js/controllers/createProfile.js +++ b/js/controllers/createProfile.js @@ -158,6 +158,8 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun return; } $scope.saveSettings(function(err) { + preconditions.checkState(!err,err); + $scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue, function(err) { $timeout(function() { form.password.$setViewValue(''); diff --git a/js/controllers/head.js b/js/controllers/head.js index 4d32b7331..a2b2e40db 100644 --- a/js/controllers/head.js +++ b/js/controllers/head.js @@ -15,7 +15,6 @@ angular.module('copayApp.controllers').controller('HeadController', function($sc }; $scope.signout = function() { - $rootScope.signingOut = true; identityService.signout(); }; diff --git a/js/controllers/home.js b/js/controllers/home.js index 9d0285644..edb25082e 100644 --- a/js/controllers/home.js +++ b/js/controllers/home.js @@ -114,7 +114,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc pinService.clear(function() { copay.logger.debug('PIN erased'); delete $rootScope['hasPin']; - applicationService.reload(); + applicationService.restart(); }); }; diff --git a/js/controllers/sidebar.js b/js/controllers/sidebar.js index 52c1f04d2..b14d23d93 100644 --- a/js/controllers/sidebar.js +++ b/js/controllers/sidebar.js @@ -27,7 +27,6 @@ angular.module('copayApp.controllers').controller('SidebarController', function( }]; $scope.signout = function() { - $rootScope.signingOut = true; identityService.signout(); }; diff --git a/js/services/applicationService.js b/js/services/applicationService.js index 4c3bade19..80a2cc02c 100644 --- a/js/services/applicationService.js +++ b/js/services/applicationService.js @@ -1,22 +1,28 @@ 'use strict'; angular.module('copayApp.services') - .factory('applicationService', function() { + .factory('applicationService', function($rootScope, $location, $timeout) { var root = {}; var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id; root.restart = function() { - - // Go home reloading the application - var hashIndex = window.location.href.indexOf('#!/'); - if (isChromeApp) { - chrome.runtime.reload(); + if (window.cordova !== undefined) { + $rootScope.iden = $rootScope.wallet = undefined; + // NOP. no need to restart on cordova apps. + $location.path('/'); + $timeout(function(){ + $rootScope.$digest(); + },1); + } else { - window.location = window.location.href.substr(0, hashIndex); - } - }; - root.reload = function() { - window.location.reload(); + // Go home reloading the application + var hashIndex = window.location.href.indexOf('#!/'); + if (isChromeApp) { + chrome.runtime.reload(); + } else { + window.location = window.location.href.substr(0, hashIndex); + } + } }; return root; diff --git a/js/services/identityService.js b/js/services/identityService.js index 1c9c14468..d949bffc7 100644 --- a/js/services/identityService.js +++ b/js/services/identityService.js @@ -328,10 +328,12 @@ angular.module('copayApp.services') }; root.signout = function() { + $rootScope.signingOut = true; if ($rootScope.iden) { $rootScope.iden.store({ noWallets: true }, function() { + $rootScope.signingOut = false; $rootScope.iden.close(); }); }