fix reload in cordova

This commit is contained in:
Matias Alejo Garcia 2014-12-06 21:07:26 -03:00
commit 984a7a6651
6 changed files with 22 additions and 14 deletions

View file

@ -158,6 +158,8 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
return; return;
} }
$scope.saveSettings(function(err) { $scope.saveSettings(function(err) {
preconditions.checkState(!err,err);
$scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue, function(err) { $scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue, function(err) {
$timeout(function() { $timeout(function() {
form.password.$setViewValue(''); form.password.$setViewValue('');

View file

@ -15,7 +15,6 @@ angular.module('copayApp.controllers').controller('HeadController', function($sc
}; };
$scope.signout = function() { $scope.signout = function() {
$rootScope.signingOut = true;
identityService.signout(); identityService.signout();
}; };

View file

@ -114,7 +114,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
pinService.clear(function() { pinService.clear(function() {
copay.logger.debug('PIN erased'); copay.logger.debug('PIN erased');
delete $rootScope['hasPin']; delete $rootScope['hasPin'];
applicationService.reload(); applicationService.restart();
}); });
}; };

View file

@ -27,7 +27,6 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
}]; }];
$scope.signout = function() { $scope.signout = function() {
$rootScope.signingOut = true;
identityService.signout(); identityService.signout();
}; };

View file

@ -1,22 +1,28 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('applicationService', function() { .factory('applicationService', function($rootScope, $location, $timeout) {
var root = {}; var root = {};
var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id; var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id;
root.restart = function() { root.restart = function() {
if (window.cordova !== undefined) {
// Go home reloading the application $rootScope.iden = $rootScope.wallet = undefined;
var hashIndex = window.location.href.indexOf('#!/'); // NOP. no need to restart on cordova apps.
if (isChromeApp) { $location.path('/');
chrome.runtime.reload(); $timeout(function(){
$rootScope.$digest();
},1);
} else { } else {
window.location = window.location.href.substr(0, hashIndex);
}
};
root.reload = function() { // Go home reloading the application
window.location.reload(); var hashIndex = window.location.href.indexOf('#!/');
if (isChromeApp) {
chrome.runtime.reload();
} else {
window.location = window.location.href.substr(0, hashIndex);
}
}
}; };
return root; return root;

View file

@ -328,10 +328,12 @@ angular.module('copayApp.services')
}; };
root.signout = function() { root.signout = function() {
$rootScope.signingOut = true;
if ($rootScope.iden) { if ($rootScope.iden) {
$rootScope.iden.store({ $rootScope.iden.store({
noWallets: true noWallets: true
}, function() { }, function() {
$rootScope.signingOut = false;
$rootScope.iden.close(); $rootScope.iden.close();
}); });
} }