From eadaa8c06d682045d4324dc7495b1d9c25eb641e Mon Sep 17 00:00:00 2001 From: Sylvain Jermini Date: Fri, 16 Dec 2022 14:22:47 +0100 Subject: [PATCH] display correctly org on first load #1127 --- frontend-admin/src/app/app.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend-admin/src/app/app.component.ts b/frontend-admin/src/app/app.component.ts index 06d9e2ca84..c2c88b80fe 100644 --- a/frontend-admin/src/app/app.component.ts +++ b/frontend-admin/src/app/app.component.ts @@ -1,8 +1,8 @@ import { Component, OnInit } from '@angular/core'; -import { ActivationEnd, Router } from '@angular/router'; +import { ActivatedRoute, ActivationEnd, Router } from '@angular/router'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { TranslateService } from '@ngx-translate/core'; -import { filter, map, Observable, of, tap, zip } from 'rxjs'; +import { combineLatest, filter, map, Observable, of } from 'rxjs'; import { Organization } from './model/organization'; import { UserInfo } from './model/user'; import { OrgSelectorComponent } from './org-selector/org-selector.component'; @@ -36,10 +36,10 @@ export class AppComponent implements OnInit { this.organizations$ = this.organizationService.getOrganizations(); this.organizationId$ = this.router.events.pipe(filter(a => a instanceof ActivationEnd), map(a => { const ae = a as ActivationEnd; - return ae.snapshot.paramMap.get('organizationId'); + return ae.snapshot.params['organizationId']; })); this.currentUser$ = this.userService.getCurrent(); - this.currentOrganization$ = zip(this.organizationId$, this.organizations$) + this.currentOrganization$ = combineLatest([this.organizationId$, this.organizations$]) .pipe(map(([id, orgs]) => orgs.find(o => id !== null && o.id === Number.parseInt(id)))); }