From a604b1d6a04a4608d8f0a00ca3fc2d362c522798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 27 Aug 2019 16:28:50 +0200 Subject: [PATCH] MOBILE-3068 splitview: Force only one push at a time --- src/components/split-view/split-view.ts | 36 ++++++++++++++++--------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/components/split-view/split-view.ts b/src/components/split-view/split-view.ts index 3e26f6e86..ca807f10d 100644 --- a/src/components/split-view/split-view.ts +++ b/src/components/split-view/split-view.ts @@ -60,6 +60,7 @@ export class CoreSplitViewComponent implements OnInit, OnDestroy { protected ignoreSplitChanged = false; protected audioCaptureSubscription: Subscription; protected languageChangedSubscription: Subscription; + protected pushOngoing: boolean; // Empty placeholder for the 'detail' page. detailPage: any = null; @@ -185,20 +186,29 @@ export class CoreSplitViewComponent implements OnInit, OnDestroy { * @param {boolean} [retrying] Whether it's retrying. */ push(page: any, params?: any, retrying?: boolean): void { - if (typeof this.isEnabled == 'undefined' && !retrying) { - // Hasn't calculated if it's enabled yet. Wait a bit and try again. - setTimeout(() => { - this.push(page, params, true); - }, 200); - } else { - if (this.isEnabled) { - this.detailNav.setRoot(page, params); + // Check there's no ongoing push. + if (!this.pushOngoing) { + if (typeof this.isEnabled == 'undefined' && !retrying) { + // Hasn't calculated if it's enabled yet. Wait a bit and try again. + setTimeout(() => { + this.push(page, params, true); + }, 200); } else { - this.loadDetailPage = { - component: page, - data: params - }; - this.masterNav.push(page, params); + this.pushOngoing = true; + let promise; + + if (this.isEnabled) { + promise = this.detailNav.setRoot(page, params); + } else { + this.loadDetailPage = { + component: page, + data: params + }; + promise = this.masterNav.push(page, params); + } + promise.finally(() => { + this.pushOngoing = false; + }); } } }