From 2992a0da4c7ebe41f9334d783ddbd2683b9c2355 Mon Sep 17 00:00:00 2001 From: Basim Mohammed <107759928+Basimohd@users.noreply.github.com> Date: Wed, 25 Oct 2023 23:57:41 +0530 Subject: [PATCH] Verify current benchmark before loading it (#2541) * Verify current benchmark before loading it * Update changelog --------- Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com> --- CHANGELOG.md | 1 + .../analysis/analysis-page.component.ts | 43 ++++++++++--------- .../portfolio/analysis/analysis-page.html | 6 +-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05081fc6c..cd02ca318 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed the chart in the account detail dialog for accounts excluded from analysis +- Verified the current benchmark before loading it on the analysis page ## 2.14.0 - 2023-10-21 diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts index ddac55046..51dcee24c 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts @@ -309,7 +309,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { } private update() { - this.isLoadingBenchmarkComparator = true; this.isLoadingInvestmentChart = true; this.dataService @@ -385,35 +384,37 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { } private updateBenchmarkDataItems() { + this.benchmarkDataItems = []; + if (this.user.settings.benchmark) { const { dataSource, symbol } = this.benchmarks.find(({ id }) => { return id === this.user.settings.benchmark; }) ?? {}; - this.dataService - .fetchBenchmarkBySymbol({ - dataSource, - symbol, - startDate: this.firstOrderDate - }) - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ marketData }) => { - this.benchmarkDataItems = marketData.map(({ date, value }) => { - return { - date, - value - }; - }); + if (dataSource && symbol) { + this.isLoadingBenchmarkComparator = true; - this.isLoadingBenchmarkComparator = false; + this.dataService + .fetchBenchmarkBySymbol({ + dataSource, + symbol, + startDate: this.firstOrderDate + }) + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(({ marketData }) => { + this.benchmarkDataItems = marketData.map(({ date, value }) => { + return { + date, + value + }; + }); - this.changeDetectorRef.markForCheck(); - }); - } else { - this.benchmarkDataItems = []; + this.isLoadingBenchmarkComparator = false; - this.isLoadingBenchmarkComparator = false; + this.changeDetectorRef.markForCheck(); + }); + } } } } diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html index 3ae58595e..f7af5d476 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html @@ -3,7 +3,7 @@
@@ -23,7 +23,7 @@ [benchmarks]="benchmarks" [colorScheme]="user?.settings?.colorScheme" [daysInMarket]="daysInMarket" - [isLoading]="isLoadingBenchmarkComparator" + [isLoading]="isLoadingBenchmarkComparator || isLoadingInvestmentChart" [locale]="user?.settings?.locale" [performanceDataItems]="performanceDataItemsInPercentage" [user]="user" @@ -149,7 +149,7 @@ [daysInMarket]="daysInMarket" [historicalDataItems]="performanceDataItems" [isInPercent]="hasImpersonationId || user.settings.isRestrictedView" - [isLoading]="isLoadingBenchmarkComparator" + [isLoading]="isLoadingInvestmentChart" [locale]="user?.settings?.locale" [range]="user?.settings?.dateRange" >