From 27e925b84fde8e40028b9e9599d9ed6aa29a41cd Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sat, 11 Jun 2016 23:08:30 -0300 Subject: [PATCH] fix url handling on cold start --- src/js/routes.js | 2 +- src/js/services/openURL.js | 17 ++++++++++------- src/js/services/profileService.js | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/js/routes.js b/src/js/routes.js index ca9048f77..26386c4aa 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -518,7 +518,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }); }) - .run(function($rootScope, $state, $location, $log, $timeout, $ionicPlatform, platformInfo, profileService, uxLanguage, animationService, go, gettextCatalog) { + .run(function($rootScope, $state, $location, $log, $timeout, $ionicPlatform, platformInfo, profileService, uxLanguage, go, gettextCatalog) { $ionicPlatform.ready(function() { if (platformInfo.isCordova) { diff --git a/src/js/services/openURL.js b/src/js/services/openURL.js index 31f0c72b8..c154d94a7 100644 --- a/src/js/services/openURL.js +++ b/src/js/services/openURL.js @@ -24,9 +24,12 @@ angular.module('copayApp.services').factory('openURLService', function($rootScop if (!profileService.isBound) { $log.warn('Profile not bound yet. Waiting'); - return $rootScope.$on('Local/ProfileBound', function(){ - $log.warn('Profile ready, retrying...'); - handleOpenURL(args); + return $rootScope.$on('Local/ProfileBound', function() { + // Wait ux to settle + setTimeout(function() { + $log.warn('Profile ready, retrying...'); + handleOpenURL(args); + }, 2000); }); }; @@ -53,10 +56,10 @@ angular.module('copayApp.services').factory('openURLService', function($rootScop document.addEventListener('handleopenurl', handleOpenURL, false); var x = lodash.find(root.registeredUriHandlers, function(x) { - return url.indexOf(x.startsWith) == 0 || - url.indexOf('web+' + x.startsWith) == 0 || // web protocols - url.indexOf(x.startsWith.replace(':','://')) == 0 // from mobile devices - ; + return url.indexOf(x.startsWith) == 0 || + url.indexOf('web+' + x.startsWith) == 0 || // web protocols + url.indexOf(x.startsWith.replace(':', '://')) == 0 // from mobile devices + ; }); if (x) { diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index a3352c869..f1844be49 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -171,7 +171,7 @@ angular.module('copayApp.services') } root.isBound = true; - $root.$emit('Local/ProfileBound'); + $rootScope.$emit('Local/ProfileBound'); return cb(); }); });