fix blank page

This commit is contained in:
Gabriel Bazán 2015-11-24 17:16:52 -03:00
commit fd32a1ec91
3 changed files with 44 additions and 31 deletions

View file

@ -1,10 +1,9 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('disclaimerController', angular.module('copayApp.controllers').controller('disclaimerController',
function($scope, $timeout, $log, profileService, isCordova, storageService, gettextCatalog, uxLanguage, go) { function($scope, $timeout, $log, profileService, isCordova, storageService, applicationService, gettextCatalog, uxLanguage, go) {
self = this; self = this;
$scope.lang = uxLanguage.currentLanguage; $scope.lang = uxLanguage.currentLanguage;
$scope.goHome = function() { $scope.goHome = function() {
storageService.setCopayDisclaimerFlag(function(err) { storageService.setCopayDisclaimerFlag(function(err) {
go.walletHome(); go.walletHome();
@ -16,14 +15,13 @@ angular.module('copayApp.controllers').controller('disclaimerController',
profileService.create({}, function(err) { profileService.create({}, function(err) {
if (err) { if (err) {
$log.warn(err);
if (err == 'EEXISTS') { if (err == 'EEXISTS') {
storageService.getCopayDisclaimerFlag(function(err, val) { storageService.getCopayDisclaimerFlag(function(err, val) {
if (val) return go.walletHome(); if (val) return go.walletHome();
$scope.creatingProfile = false; $scope.creatingProfile = false;
}); });
} else { } else {
$log.warn(err);
$scope.error = err; $scope.error = err;
$scope.$apply(); $scope.$apply();
$timeout(function() { $timeout(function() {
@ -38,6 +36,8 @@ angular.module('copayApp.controllers').controller('disclaimerController',
}); });
}; };
create(); if (!profileService.profile)
create();
else
applicationService.restart();
}); });

View file

@ -457,27 +457,33 @@ angular
url: '/cordova/:status/:isHome', url: '/cordova/:status/:isHome',
views: { views: {
'main': { 'main': {
controller: function($rootScope, $state, $stateParams, $timeout, go, isCordova, storageService) { controller: function($rootScope, $state, $log, $stateParams, $timeout, go, isCordova, storageService) {
if ($stateParams.status == "pause")
return;
switch ($stateParams.status) {
case 'resume':
$rootScope.$emit('Local/Resume');
break;
case 'backbutton':
if (isCordova && $stateParams.isHome == 'true' && !$rootScope.modalOpened) {
navigator.app.exitApp();
} else {
$rootScope.$emit('closeModal');
}
break;
};
storageService.getCopayDisclaimerFlag(function(err, val) { storageService.getCopayDisclaimerFlag(function(err, val) {
if (!val) navigator.app.exitApp();
$timeout(function() { $log.debug('### State: ', $stateParams.status);
$rootScope.$emit('Local/SetTab', 'walletHome', true); switch ($stateParams.status) {
}, 100); case 'resume':
go.walletHome(); $rootScope.$emit('Local/Resume');
break;
case 'backbutton':
var shouldExit = $stateParams.isHome == 'true' || !val;
if (isCordova && shouldExit && !$rootScope.modalOpened) {
return navigator.app.exitApp();
} else {
$rootScope.$emit('closeModal');
}
break;
};
if (val) {
go.walletHome(true);
} else {
$state.transitionTo('disclaimer');
}
}); });
} }
} }

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('go', function($window, $rootScope, $location, $state, profileService, nodeWebkit) { angular.module('copayApp.services').factory('go', function($window, $rootScope, $location, $state, $timeout, profileService, nodeWebkit) {
var root = {}; var root = {};
var hideSidebars = function() { var hideSidebars = function() {
@ -32,8 +32,7 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
root.openExternalLink = function(url, target) { root.openExternalLink = function(url, target) {
if (nodeWebkit.isDefined()) { if (nodeWebkit.isDefined()) {
nodeWebkit.openExternalLink(url); nodeWebkit.openExternalLink(url);
} } else {
else {
target = target || '_blank'; target = target || '_blank';
var ref = window.open(url, target, 'location=no'); var ref = window.open(url, target, 'location=no');
} }
@ -53,14 +52,22 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
toggleSidebar(invert); toggleSidebar(invert);
}; };
root.walletHome = function() { root.walletHome = function(delayed) {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
if (fc && !fc.isComplete()) { if (fc && !fc.isComplete()) {
root.path('copayers'); root.path('copayers');
} else { } else {
root.path('walletHome', function() { if (delayed) {
$rootScope.$emit('Local/SetTab', 'walletHome', true); $timeout(function() {
}); root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'walletHome', true);
});
}, 100);
} else {
root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'walletHome', true);
});
}
} }
}; };