From d1f997e75f5e32a9df8b897df9303c818da5bf88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20G=C3=BCnther?= Date: Thu, 4 Sep 2025 15:49:30 +0200 Subject: [PATCH] fix: apply PR feedback for currency gatherSymbol implementation - Consolidate admin data fetching into single initialize() method - Remove unnecessary asset profile creation for currencies - Remove DataSource.MANUAL fallback in exchange rate data source assignment - Keep currency gatherSymbol logic in onSubmit method as requested This addresses feedback from PR #5434 review comments. --- .../create-asset-profile-dialog.component.ts | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts b/apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts index b4403fe3d..c4b4b0b26 100644 --- a/apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts +++ b/apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts @@ -70,8 +70,7 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy { ) {} public ngOnInit() { - this.initializeCustomCurrencies(); - this.initializeExchangeRateDataSource(); + this.initialize(); this.createAssetProfileForm = this.formBuilder.group( { @@ -121,14 +120,7 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy { }) .pipe( switchMap(() => { - // Add the currency asset profile first - return this.adminService.addAssetProfile({ - dataSource: this.exchangeRateDataSource, - symbol: `${currency}${DEFAULT_CURRENCY}` - }); - }), - switchMap(() => { - // Then gather historical data for the currency + // Gather historical data for the currency return this.adminService.gatherSymbol({ dataSource: this.exchangeRateDataSource, symbol: `${currency}${DEFAULT_CURRENCY}` @@ -190,28 +182,18 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy { return { atLeastOneValid: true }; } - private initializeCustomCurrencies() { + private initialize() { this.adminService .fetchAdminData() .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ settings }) => { + .subscribe(({ settings, dataProviders }) => { this.customCurrencies = settings[PROPERTY_CURRENCIES] as string[]; - this.changeDetectorRef.markForCheck(); - }); - } - - private initializeExchangeRateDataSource() { - this.adminService - .fetchAdminData() - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ dataProviders }) => { const exchangeRateProvider = dataProviders.find( (provider) => provider.useForExchangeRates ); - this.exchangeRateDataSource = - exchangeRateProvider?.dataSource || DataSource.MANUAL; + this.exchangeRateDataSource = exchangeRateProvider?.dataSource; this.changeDetectorRef.markForCheck(); });