fix(loading): prevent loading service from disabling all future back button behavior. Fixes #2214

This commit is contained in:
Perry Govier
2014-10-07 14:19:20 -05:00
parent 4f76a9660b
commit 34934f636e
2 changed files with 10 additions and 7 deletions

View File

@@ -133,6 +133,13 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
);
}
deregisterBackAction();
//Disable hardware back button while loading
deregisterBackAction = $ionicPlatform.registerBackButtonAction(
angular.noop,
PLATFORM_BACK_BUTTON_PRIORITY_LOADING
);
templatePromise.then(function(html) {
if (html) {
var loading = self.element.children();
@@ -155,6 +162,8 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
this.isShown = true;
};
loader.hide = function() {
deregisterBackAction();
if (this.isShown) {
if (this.hasBackdrop) {
$ionicBackdrop.release();
@@ -185,12 +194,6 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
loadingShowDelay = $timeout(angular.noop, delay);
loadingShowDelay.then(getLoader).then(function(loader) {
deregisterBackAction();
//Disable hardware back button while loading
deregisterBackAction = $ionicPlatform.registerBackButtonAction(
angular.noop,
PLATFORM_BACK_BUTTON_PRIORITY_LOADING
);
return loader.show(options);
});
@@ -208,7 +211,6 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
}
function hideLoader() {
deregisterBackAction();
$timeout.cancel(loadingShowDelay);
getLoader().then(function(loader) {
loader.hide();

View File

@@ -189,6 +189,7 @@ describe('$ionicLoading service', function() {
$timeout.flush();
expect(deregisterSpy).not.toHaveBeenCalled();
$ionicLoading.hide();
$timeout.flush();
expect(deregisterSpy).toHaveBeenCalled();
}));
});