mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(loading): prevent loading service from disabling all future back button behavior. Fixes #2214
This commit is contained in:
16
js/angular/service/loading.js
vendored
16
js/angular/service/loading.js
vendored
@@ -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();
|
||||
|
||||
@@ -189,6 +189,7 @@ describe('$ionicLoading service', function() {
|
||||
$timeout.flush();
|
||||
expect(deregisterSpy).not.toHaveBeenCalled();
|
||||
$ionicLoading.hide();
|
||||
$timeout.flush();
|
||||
expect(deregisterSpy).toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user