From be558b73d00ac87b00003e43111e66ef45cc528d Mon Sep 17 00:00:00 2001 From: illfixit <66363651+illfixit@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:49:44 +0200 Subject: [PATCH] fix: already using --- .../catalog-browser-page.component.ts | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/app/routes/connector-ui/catalog-browser-page/catalog-browser-page/catalog-browser-page.component.ts b/src/app/routes/connector-ui/catalog-browser-page/catalog-browser-page/catalog-browser-page.component.ts index 9a3e2687..cd1393c2 100644 --- a/src/app/routes/connector-ui/catalog-browser-page/catalog-browser-page/catalog-browser-page.component.ts +++ b/src/app/routes/connector-ui/catalog-browser-page/catalog-browser-page/catalog-browser-page.component.ts @@ -9,7 +9,7 @@ import { sampleTime, switchMap, } from 'rxjs'; -import {filter, map} from 'rxjs/operators'; +import {filter, map, takeUntil} from 'rxjs/operators'; import {TranslateService} from '@ngx-translate/core'; import {ConnectorLimitsService} from '../../../../core/services/connector-limits.service'; import {DataOffer} from '../../../../core/services/models/data-offer'; @@ -55,7 +55,7 @@ export class CatalogBrowserPageComponent implements OnInit, OnDestroy { this.data = data; this.data$.next(data); }); - this.presetProvidersMessage = this.buildPresetCatalogUrlsMessage(); + this.buildPresetCatalogUrlsMessage(); } onDataOfferClick(dataOffer: DataOffer) { @@ -87,15 +87,19 @@ export class CatalogBrowserPageComponent implements OnInit, OnDestroy { this.fetch$.next(null); } - private buildPresetCatalogUrlsMessage(): string { - const urls = this.catalogApiUrlService.getPresetProviders(); - const usage = this.translateService.instant('catalog_browser_page.usage'); - if (!urls.length) { - return ''; - } - return `${usage} ${urls.length > 1 ? ` (${urls.length})` : ''}: ${urls.join( - ', ', - )}`; + private buildPresetCatalogUrlsMessage() { + this.translateService + .get(['catalog_browser_page.usage']) + .pipe(takeUntil(this.ngOnDestroy$)) + .subscribe((strings) => { + const urls = this.catalogApiUrlService.getPresetProviders(); + const usage = strings['catalog_browser_page.usage']; + this.presetProvidersMessage = !urls.length + ? '' + : `${usage} ${ + urls.length > 1 ? ` (${urls.length})` : '' + }: ${urls.join(', ')}`; + }); } private searchText$(): Observable {