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 3b089024c..53b93246c 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 @@ -202,7 +202,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { public onChangeGroupBy(aMode: GroupBy) { this.mode = aMode; - this.update(); + this.fetchDividendsAndInvestments(); } public ngOnDestroy() { @@ -210,6 +210,34 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { this.unsubscribeSubject.complete(); } + private fetchDividendsAndInvestments() { + this.dataService + .fetchDividends({ + filters: this.activeFilters, + groupBy: this.mode, + range: this.user?.settings?.dateRange + }) + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(({ dividends }) => { + this.dividendsByMonth = dividends; + + this.changeDetectorRef.markForCheck(); + }); + + this.dataService + .fetchInvestments({ + filters: this.activeFilters, + groupBy: this.mode, + range: this.user?.settings?.dateRange + }) + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(({ investments }) => { + this.investmentsByMonth = investments; + + this.changeDetectorRef.markForCheck(); + }); + } + private openPositionDialog({ dataSource, symbol @@ -293,32 +321,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { this.changeDetectorRef.markForCheck(); }); - this.dataService - .fetchDividends({ - filters: this.activeFilters, - groupBy: this.mode, - range: this.user?.settings?.dateRange - }) - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ dividends }) => { - this.dividendsByMonth = dividends; - - this.changeDetectorRef.markForCheck(); - }); - - this.dataService - .fetchInvestments({ - filters: this.activeFilters, - groupBy: this.mode, - range: this.user?.settings?.dateRange - }) - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ investments }) => { - this.investmentsByMonth = investments; - - this.changeDetectorRef.markForCheck(); - }); - this.dataService .fetchPositions({ filters: this.activeFilters, @@ -342,6 +344,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { this.changeDetectorRef.markForCheck(); }); + this.fetchDividendsAndInvestments(); this.changeDetectorRef.markForCheck(); }