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

@ -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;