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

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

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

Loading…
Cancel
Save