diff --git a/packages/integration/src/lib/catalog/catalog-browser-tool/catalog-browser-tool.component.ts b/packages/integration/src/lib/catalog/catalog-browser-tool/catalog-browser-tool.component.ts index 30a4aaa93a..15b4852077 100644 --- a/packages/integration/src/lib/catalog/catalog-browser-tool/catalog-browser-tool.component.ts +++ b/packages/integration/src/lib/catalog/catalog-browser-tool/catalog-browser-tool.component.ts @@ -16,7 +16,7 @@ import { IgoMap } from '@igo2/geo'; -import { BehaviorSubject, Subscription } from 'rxjs'; +import { BehaviorSubject, Subscription, combineLatest } from 'rxjs'; import { take } from 'rxjs/operators'; import { MapState } from '../../map/map.state'; @@ -52,11 +52,6 @@ export class CatalogBrowserToolComponent implements OnInit, OnDestroy { */ private catalog$$: Subscription; - /** - * Subscription for authentication - */ - private authenticate$$: Subscription; - /** * Whether a group can be toggled when it's collapsed */ @@ -82,20 +77,18 @@ export class CatalogBrowserToolComponent implements OnInit, OnDestroy { */ ngOnInit() { const catalogStore = this.catalogState.catalogStore; - this.catalog$$ = catalogStore.stateView - .firstBy$( - (record: EntityRecord) => record.state.selected === true - ) - .subscribe((record: EntityRecord) => { - if (record && record.entity) { - const catalog = record.entity; - this.catalog = catalog; - } - }); - this.authenticate$$ = this.authService.authenticate$.subscribe(() => { - this.loadCatalogItems(this.catalog); - }); + const catalog$ = catalogStore.stateView.firstBy$( + (record: EntityRecord) => record.state.selected === true + ); + const authenticate$ = this.authService.authenticate$; + this.catalog$$ = combineLatest([catalog$, authenticate$]).subscribe( + ([record, authenticate]) => { + const catalog = record.entity; + this.catalog = catalog; + this.loadCatalogItems(this.catalog); + } + ); } /** @@ -103,7 +96,6 @@ export class CatalogBrowserToolComponent implements OnInit, OnDestroy { */ ngOnDestroy() { this.catalog$$.unsubscribe(); - this.authenticate$$.unsubscribe(); } /**