From 79655e1fbe9b933d250e5c0f985e23839d050508 Mon Sep 17 00:00:00 2001 From: bnymncoskuner Date: Mon, 12 Jul 2021 18:48:40 +0300 Subject: [PATCH] fix: reading wrong data for tenantBoxVisible from route config --- .../src/lib/auth-wrapper.service.ts | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts b/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts index 44f53c7eef..7bad8ef96a 100644 --- a/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts +++ b/npm/ng-packs/packages/account-core/src/lib/auth-wrapper.service.ts @@ -17,14 +17,12 @@ export class AuthWrapperService { tenantBoxKey = 'Account.TenantBoxComponent'; route: ActivatedRoute; - private _tenantBoxVisible = true; - - private setTenantBoxVisibility = () => { - this._tenantBoxVisible = this.route.snapshot.firstChild.data.tenantBoxVisible ?? true; - }; + get isTenantBoxVisibleForCurrentRoute() { + return this.getMostInnerChild().data.tenantBoxVisible ?? true; + } get isTenantBoxVisible() { - return this._tenantBoxVisible && this.multiTenancy.isTenantBoxVisible; + return this.isTenantBoxVisibleForCurrentRoute && this.multiTenancy.isTenantBoxVisible; } constructor( @@ -33,6 +31,16 @@ export class AuthWrapperService { injector: Injector, ) { this.route = injector.get(ActivatedRoute); - this.setTenantBoxVisibility(); + } + + private getMostInnerChild() { + let child = this.route.snapshot; + let depth = 0; + const depthLimit = 10; + while (child.firstChild && depth < depthLimit) { + child = child.firstChild; + depth++; + } + return child; } }