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() {
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();
});

Loading…
Cancel
Save