Fix app initialisation
This commit is contained in:
parent
e519517167
commit
d27a77cb1f
1 changed files with 79 additions and 82 deletions
169
src/js/routes.js
169
src/js/routes.js
|
|
@ -1096,101 +1096,98 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
uxLanguage.init();
|
uxLanguage.init();
|
||||||
|
|
||||||
$ionicPlatform.ready(function() {
|
$ionicPlatform.ready(function() {
|
||||||
if (platformInfo.isCordova) {
|
if (screen.width < 768)
|
||||||
|
screen.lockOrientation('portrait');
|
||||||
|
|
||||||
if (screen.width < 768)
|
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
|
||||||
screen.lockOrientation('portrait');
|
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
|
||||||
|
cordova.plugins.Keyboard.disableScroll(true);
|
||||||
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
|
|
||||||
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
|
|
||||||
cordova.plugins.Keyboard.disableScroll(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('native.keyboardshow', function() {
|
|
||||||
document.body.classList.add('keyboard-open');
|
|
||||||
});
|
|
||||||
|
|
||||||
$ionicPlatform.registerBackButtonAction(function(e) {
|
|
||||||
|
|
||||||
//from root tabs view
|
|
||||||
var matchHome = $ionicHistory.currentStateName() == 'tabs.home' ? true : false;
|
|
||||||
var matchReceive = $ionicHistory.currentStateName() == 'tabs.receive' ? true : false;
|
|
||||||
var matchScan = $ionicHistory.currentStateName() == 'tabs.scan' ? true : false;
|
|
||||||
var matchSend = $ionicHistory.currentStateName() == 'tabs.send' ? true : false;
|
|
||||||
var matchSettings = $ionicHistory.currentStateName() == 'tabs.settings' ? true : false;
|
|
||||||
var fromTabs = matchHome | matchReceive | matchScan | matchSend | matchSettings;
|
|
||||||
|
|
||||||
//onboarding with no back views
|
|
||||||
var matchWelcome = $ionicHistory.currentStateName() == 'onboarding.welcome' ? true : false;
|
|
||||||
var matchCollectEmail = $ionicHistory.currentStateName() == 'onboarding.collectEmail' ? true : false;
|
|
||||||
var matchBackupRequest = $ionicHistory.currentStateName() == 'onboarding.backupRequest' ? true : false;
|
|
||||||
var matchNotifications = $ionicHistory.currentStateName() == 'onboarding.notifications' ? true : false;
|
|
||||||
|
|
||||||
var fromOnboarding = matchCollectEmail | matchBackupRequest | matchNotifications | matchWelcome;
|
|
||||||
|
|
||||||
if ($ionicHistory.backView() && !fromTabs && !fromOnboarding) {
|
|
||||||
$ionicHistory.goBack();
|
|
||||||
} else
|
|
||||||
if ($rootScope.backButtonPressedOnceToExit) {
|
|
||||||
ionic.Platform.exitApp();
|
|
||||||
} else {
|
|
||||||
$rootScope.backButtonPressedOnceToExit = true;
|
|
||||||
window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit'));
|
|
||||||
$timeout(function() {
|
|
||||||
$rootScope.backButtonPressedOnceToExit = false;
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
e.preventDefault();
|
|
||||||
}, 101);
|
|
||||||
|
|
||||||
$ionicPlatform.on('pause', function() {
|
|
||||||
// Nothing to do
|
|
||||||
});
|
|
||||||
|
|
||||||
$ionicPlatform.on('resume', function() {
|
|
||||||
// Nothing to do
|
|
||||||
});
|
|
||||||
|
|
||||||
$ionicPlatform.on('menubutton', function() {
|
|
||||||
window.location = '#/preferences';
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$log.info('Init profile...');
|
window.addEventListener('native.keyboardshow', function() {
|
||||||
// Try to open local profile
|
document.body.classList.add('keyboard-open');
|
||||||
profileService.loadAndBindProfile(function(err) {
|
});
|
||||||
$ionicHistory.nextViewOptions({
|
|
||||||
disableAnimate: true
|
$ionicPlatform.registerBackButtonAction(function(e) {
|
||||||
});
|
|
||||||
if (err) {
|
//from root tabs view
|
||||||
if (err.message && err.message.match('NOPROFILE')) {
|
var matchHome = $ionicHistory.currentStateName() == 'tabs.home' ? true : false;
|
||||||
$log.debug('No profile... redirecting');
|
var matchReceive = $ionicHistory.currentStateName() == 'tabs.receive' ? true : false;
|
||||||
|
var matchScan = $ionicHistory.currentStateName() == 'tabs.scan' ? true : false;
|
||||||
|
var matchSend = $ionicHistory.currentStateName() == 'tabs.send' ? true : false;
|
||||||
|
var matchSettings = $ionicHistory.currentStateName() == 'tabs.settings' ? true : false;
|
||||||
|
var fromTabs = matchHome | matchReceive | matchScan | matchSend | matchSettings;
|
||||||
|
|
||||||
|
//onboarding with no back views
|
||||||
|
var matchWelcome = $ionicHistory.currentStateName() == 'onboarding.welcome' ? true : false;
|
||||||
|
var matchCollectEmail = $ionicHistory.currentStateName() == 'onboarding.collectEmail' ? true : false;
|
||||||
|
var matchBackupRequest = $ionicHistory.currentStateName() == 'onboarding.backupRequest' ? true : false;
|
||||||
|
var matchNotifications = $ionicHistory.currentStateName() == 'onboarding.notifications' ? true : false;
|
||||||
|
|
||||||
|
var fromOnboarding = matchCollectEmail | matchBackupRequest | matchNotifications | matchWelcome;
|
||||||
|
|
||||||
|
if ($ionicHistory.backView() && !fromTabs && !fromOnboarding) {
|
||||||
|
$ionicHistory.goBack();
|
||||||
|
} else
|
||||||
|
if ($rootScope.backButtonPressedOnceToExit) {
|
||||||
|
ionic.Platform.exitApp();
|
||||||
|
} else {
|
||||||
|
$rootScope.backButtonPressedOnceToExit = true;
|
||||||
|
window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit'));
|
||||||
|
$timeout(function() {
|
||||||
|
$rootScope.backButtonPressedOnceToExit = false;
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
}, 101);
|
||||||
|
|
||||||
|
$ionicPlatform.on('pause', function() {
|
||||||
|
// Nothing to do
|
||||||
|
});
|
||||||
|
|
||||||
|
$ionicPlatform.on('resume', function() {
|
||||||
|
// Nothing to do
|
||||||
|
});
|
||||||
|
|
||||||
|
$ionicPlatform.on('menubutton', function() {
|
||||||
|
window.location = '#/preferences';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$log.info('Init profile...');
|
||||||
|
// Try to open local profile
|
||||||
|
profileService.loadAndBindProfile(function(err) {
|
||||||
|
$ionicHistory.nextViewOptions({
|
||||||
|
disableAnimate: true
|
||||||
|
});
|
||||||
|
if (err) {
|
||||||
|
if (err.message && err.message.match('NOPROFILE')) {
|
||||||
|
$log.debug('No profile... redirecting');
|
||||||
|
$state.go('onboarding.welcome');
|
||||||
|
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
|
||||||
|
if (lodash.isEmpty(profileService.getWallets())) {
|
||||||
|
$log.debug('No wallets and no disclaimer... redirecting');
|
||||||
$state.go('onboarding.welcome');
|
$state.go('onboarding.welcome');
|
||||||
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
|
|
||||||
if (lodash.isEmpty(profileService.getWallets())) {
|
|
||||||
$log.debug('No wallets and no disclaimer... redirecting');
|
|
||||||
$state.go('onboarding.welcome');
|
|
||||||
} else {
|
|
||||||
$log.debug('Display disclaimer... redirecting');
|
|
||||||
$state.go('onboarding.disclaimer', {
|
|
||||||
resume: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(err); // TODO
|
$log.debug('Display disclaimer... redirecting');
|
||||||
|
$state.go('onboarding.disclaimer', {
|
||||||
|
resume: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
profileService.storeProfileIfDirty();
|
throw new Error(err); // TODO
|
||||||
$log.debug('Profile loaded ... Starting UX.');
|
|
||||||
scannerService.gentleInitialize();
|
|
||||||
$state.go('tabs.home');
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
profileService.storeProfileIfDirty();
|
||||||
|
$log.debug('Profile loaded ... Starting UX.');
|
||||||
|
scannerService.gentleInitialize();
|
||||||
|
$state.go('tabs.home');
|
||||||
|
}
|
||||||
|
|
||||||
// After everything have been loaded, initialize handler URL
|
// After everything have been loaded, initialize handler URL
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
openURLService.init();
|
openURLService.init();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (platformInfo.isNW) {
|
if (platformInfo.isNW) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue