Browse Source

feat(client): convert historicalDataItems and isLoadingPerformance to signals

pull/6927/head
KenTandrian 2 days ago
parent
commit
00261d2edd
  1. 15
      apps/client/src/app/components/home-overview/home-overview.component.ts
  2. 6
      apps/client/src/app/components/home-overview/home-overview.html

15
apps/client/src/app/components/home-overview/home-overview.component.ts

@ -46,8 +46,8 @@ import { DeviceDetectorService } from 'ngx-device-detector';
export class GfHomeOverviewComponent implements OnInit { export class GfHomeOverviewComponent implements OnInit {
protected readonly errors = signal<AssetProfileIdentifier[]>([]); protected readonly errors = signal<AssetProfileIdentifier[]>([]);
protected readonly hasImpersonationId = signal(false); protected readonly hasImpersonationId = signal(false);
protected historicalDataItems: LineChartItem[] | null; protected readonly historicalDataItems = signal<LineChartItem[] | null>(null);
protected isLoadingPerformance = true; protected readonly isLoadingPerformance = signal(true);
protected performance: PortfolioPerformance; protected performance: PortfolioPerformance;
protected readonly performanceLabel = $localize`Performance`; protected readonly performanceLabel = $localize`Performance`;
protected precision = 2; protected precision = 2;
@ -116,8 +116,8 @@ export class GfHomeOverviewComponent implements OnInit {
} }
private update() { private update() {
this.historicalDataItems = null; this.historicalDataItems.set(null);
this.isLoadingPerformance = true; this.isLoadingPerformance.set(true);
this.dataService this.dataService
.fetchPortfolioPerformance({ .fetchPortfolioPerformance({
@ -128,7 +128,7 @@ export class GfHomeOverviewComponent implements OnInit {
this.errors.set(errors ?? []); this.errors.set(errors ?? []);
this.performance = performance; this.performance = performance;
this.historicalDataItems = this.historicalDataItems.set(
chart?.map( chart?.map(
({ date, netPerformanceInPercentageWithCurrencyEffect }) => { ({ date, netPerformanceInPercentageWithCurrencyEffect }) => {
return { return {
@ -136,7 +136,8 @@ export class GfHomeOverviewComponent implements OnInit {
value: (netPerformanceInPercentageWithCurrencyEffect ?? 0) * 100 value: (netPerformanceInPercentageWithCurrencyEffect ?? 0) * 100
}; };
} }
) ?? null; ) ?? null
);
if ( if (
this.deviceType() === 'mobile' && this.deviceType() === 'mobile' &&
@ -146,7 +147,7 @@ export class GfHomeOverviewComponent implements OnInit {
this.precision = 0; this.precision = 0;
} }
this.isLoadingPerformance = false; this.isLoadingPerformance.set(false);
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });

6
apps/client/src/app/components/home-overview/home-overview.html

@ -69,8 +69,8 @@
unit="%" unit="%"
[class.pr-3]="deviceType() === 'mobile'" [class.pr-3]="deviceType() === 'mobile'"
[colorScheme]="user()?.settings?.colorScheme" [colorScheme]="user()?.settings?.colorScheme"
[hidden]="historicalDataItems?.length === 0" [hidden]="historicalDataItems()?.length === 0"
[historicalDataItems]="historicalDataItems" [historicalDataItems]="historicalDataItems()"
[isAnimated]="user()?.settings?.dateRange === '1d' ? false : true" [isAnimated]="user()?.settings?.dateRange === '1d' ? false : true"
[label]="performanceLabel" [label]="performanceLabel"
[locale]="user()?.settings?.locale" [locale]="user()?.settings?.locale"
@ -88,7 +88,7 @@
class="pb-4" class="pb-4"
[deviceType]="deviceType()" [deviceType]="deviceType()"
[errors]="errors()" [errors]="errors()"
[isLoading]="isLoadingPerformance" [isLoading]="isLoadingPerformance()"
[locale]="user()?.settings?.locale" [locale]="user()?.settings?.locale"
[performance]="performance" [performance]="performance"
[precision]="precision" [precision]="precision"

Loading…
Cancel
Save