fix: reading wrong data for tenantBoxVisible from route config

pull/9576/head
bnymncoskuner 4 years ago
parent 8d89178707
commit 79655e1fbe

@ -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;
}
}

Loading…
Cancel
Save