MOBILE-3068 splitview: Force only one push at a time

main
Pau Ferrer Ocaña 2019-08-27 16:28:50 +02:00
parent 886880a2f0
commit a604b1d6a0
1 changed files with 23 additions and 13 deletions

View File

@ -60,6 +60,7 @@ export class CoreSplitViewComponent implements OnInit, OnDestroy {
protected ignoreSplitChanged = false; protected ignoreSplitChanged = false;
protected audioCaptureSubscription: Subscription; protected audioCaptureSubscription: Subscription;
protected languageChangedSubscription: Subscription; protected languageChangedSubscription: Subscription;
protected pushOngoing: boolean;
// Empty placeholder for the 'detail' page. // Empty placeholder for the 'detail' page.
detailPage: any = null; detailPage: any = null;
@ -185,20 +186,29 @@ export class CoreSplitViewComponent implements OnInit, OnDestroy {
* @param {boolean} [retrying] Whether it's retrying. * @param {boolean} [retrying] Whether it's retrying.
*/ */
push(page: any, params?: any, retrying?: boolean): void { push(page: any, params?: any, retrying?: boolean): void {
if (typeof this.isEnabled == 'undefined' && !retrying) { // Check there's no ongoing push.
// Hasn't calculated if it's enabled yet. Wait a bit and try again. if (!this.pushOngoing) {
setTimeout(() => { if (typeof this.isEnabled == 'undefined' && !retrying) {
this.push(page, params, true); // Hasn't calculated if it's enabled yet. Wait a bit and try again.
}, 200); setTimeout(() => {
} else { this.push(page, params, true);
if (this.isEnabled) { }, 200);
this.detailNav.setRoot(page, params);
} else { } else {
this.loadDetailPage = { this.pushOngoing = true;
component: page, let promise;
data: params
}; if (this.isEnabled) {
this.masterNav.push(page, params); promise = this.detailNav.setRoot(page, params);
} else {
this.loadDetailPage = {
component: page,
data: params
};
promise = this.masterNav.push(page, params);
}
promise.finally(() => {
this.pushOngoing = false;
});
} }
} }
} }