Browse Source

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.
pull/5434/head
Sven Günther 4 months ago
parent
commit
d1f997e75f
  1. 28
      apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts

28
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() { public ngOnInit() {
this.initializeCustomCurrencies(); this.initialize();
this.initializeExchangeRateDataSource();
this.createAssetProfileForm = this.formBuilder.group( this.createAssetProfileForm = this.formBuilder.group(
{ {
@ -121,14 +120,7 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy {
}) })
.pipe( .pipe(
switchMap(() => { switchMap(() => {
// Add the currency asset profile first // Gather historical data for the currency
return this.adminService.addAssetProfile({
dataSource: this.exchangeRateDataSource,
symbol: `${currency}${DEFAULT_CURRENCY}`
});
}),
switchMap(() => {
// Then gather historical data for the currency
return this.adminService.gatherSymbol({ return this.adminService.gatherSymbol({
dataSource: this.exchangeRateDataSource, dataSource: this.exchangeRateDataSource,
symbol: `${currency}${DEFAULT_CURRENCY}` symbol: `${currency}${DEFAULT_CURRENCY}`
@ -190,28 +182,18 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy {
return { atLeastOneValid: true }; return { atLeastOneValid: true };
} }
private initializeCustomCurrencies() { private initialize() {
this.adminService this.adminService
.fetchAdminData() .fetchAdminData()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ settings }) => { .subscribe(({ settings, dataProviders }) => {
this.customCurrencies = settings[PROPERTY_CURRENCIES] as string[]; 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( const exchangeRateProvider = dataProviders.find(
(provider) => provider.useForExchangeRates (provider) => provider.useForExchangeRates
); );
this.exchangeRateDataSource = this.exchangeRateDataSource = exchangeRateProvider?.dataSource;
exchangeRateProvider?.dataSource || DataSource.MANUAL;
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });

Loading…
Cancel
Save