fix(angular): swiping back quickly no longer causes app to get stuck (#23125)

resolves #15154
This commit is contained in:
capc0
2021-04-01 15:57:04 +02:00
committed by GitHub
parent b7b97ce4cc
commit 28c52fd4e3
2 changed files with 6 additions and 1 deletions

View File

@ -52,7 +52,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
this._swipeGesture = swipe; this._swipeGesture = swipe;
this.nativeEl.swipeHandler = swipe ? { this.nativeEl.swipeHandler = swipe ? {
canStart: () => this.stackCtrl.canGoBack(1), canStart: () => this.stackCtrl.canGoBack(1) && !this.stackCtrl.hasRunningTask(),
onStart: () => this.stackCtrl.startBackTransition(), onStart: () => this.stackCtrl.startBackTransition(),
onEnd: shouldContinue => this.stackCtrl.endBackTransition(shouldContinue) onEnd: shouldContinue => this.stackCtrl.endBackTransition(shouldContinue)
} : undefined; } : undefined;

View File

@ -232,6 +232,10 @@ export class StackController {
return this.activeView ? this.activeView.stackId : undefined; return this.activeView ? this.activeView.stackId : undefined;
} }
hasRunningTask(): boolean {
return this.runningTask !== undefined;
}
destroy() { destroy() {
this.containerEl = undefined!; this.containerEl = undefined!;
this.views.forEach(destroyView); this.views.forEach(destroyView);
@ -294,6 +298,7 @@ export class StackController {
this.runningTask = undefined; this.runningTask = undefined;
} }
const promise = this.runningTask = task(); const promise = this.runningTask = task();
promise.finally(() => this.runningTask = undefined);
return promise; return promise;
} }
} }