From 28c52fd4e3df3d96b4ec83075a322e110e938a1a Mon Sep 17 00:00:00 2001 From: capc0 Date: Thu, 1 Apr 2021 15:57:04 +0200 Subject: [PATCH] fix(angular): swiping back quickly no longer causes app to get stuck (#23125) resolves #15154 --- angular/src/directives/navigation/ion-router-outlet.ts | 2 +- angular/src/directives/navigation/stack-controller.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/angular/src/directives/navigation/ion-router-outlet.ts b/angular/src/directives/navigation/ion-router-outlet.ts index 9c47551fb2..5c33e3d619 100644 --- a/angular/src/directives/navigation/ion-router-outlet.ts +++ b/angular/src/directives/navigation/ion-router-outlet.ts @@ -52,7 +52,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit { this._swipeGesture = swipe; this.nativeEl.swipeHandler = swipe ? { - canStart: () => this.stackCtrl.canGoBack(1), + canStart: () => this.stackCtrl.canGoBack(1) && !this.stackCtrl.hasRunningTask(), onStart: () => this.stackCtrl.startBackTransition(), onEnd: shouldContinue => this.stackCtrl.endBackTransition(shouldContinue) } : undefined; diff --git a/angular/src/directives/navigation/stack-controller.ts b/angular/src/directives/navigation/stack-controller.ts index a7713fb80a..049f251f4c 100644 --- a/angular/src/directives/navigation/stack-controller.ts +++ b/angular/src/directives/navigation/stack-controller.ts @@ -232,6 +232,10 @@ export class StackController { return this.activeView ? this.activeView.stackId : undefined; } + hasRunningTask(): boolean { + return this.runningTask !== undefined; + } + destroy() { this.containerEl = undefined!; this.views.forEach(destroyView); @@ -294,6 +298,7 @@ export class StackController { this.runningTask = undefined; } const promise = this.runningTask = task(); + promise.finally(() => this.runningTask = undefined); return promise; } }