From bc3535946c39c7070ec9911070ad13eed0552856 Mon Sep 17 00:00:00 2001 From: Amandee Ellawala <47607256+amandee27@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:16:41 +0000 Subject: [PATCH] Bugfix/do not fetch holdings in assistant for each change (#4118) * Do not fetch holdings in assistant for each change * Update changelog --- CHANGELOG.md | 1 + .../src/lib/assistant/assistant.component.ts | 46 ++++++++----------- libs/ui/src/lib/assistant/assistant.html | 4 +- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59f0c1bb5..b92efa0de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Optimized the holding selector in the assistant - Improved the language localization for German (`de`) - Upgraded `@internationalized/number` from version `3.5.2` to `3.6.0` diff --git a/libs/ui/src/lib/assistant/assistant.component.ts b/libs/ui/src/lib/assistant/assistant.component.ts index 3a5e6a2f8..a7fb0c7e2 100644 --- a/libs/ui/src/lib/assistant/assistant.component.ts +++ b/libs/ui/src/lib/assistant/assistant.component.ts @@ -167,8 +167,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { ) {} public ngOnInit() { - this.initializeFilterForm(); - this.assetClasses = Object.keys(AssetClass).map((assetClass) => { return { id: assetClass, @@ -272,12 +270,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { this.filterForm.disable({ emitEvent: false }); - if (this.hasPermissionToChangeFilters) { - this.filterForm.enable({ emitEvent: false }); - } - - this.initializeFilterForm(); - this.tags = this.user?.tags ?.filter(({ isUsed }) => { @@ -315,7 +307,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { ); } - public async initialize() { + public initialize() { this.isLoading = true; this.keyManager = new FocusKeyManager(this.assistantListItems).withWrap(); this.searchResults = { @@ -335,7 +327,25 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { this.isLoading = false; this.setIsOpen(true); - this.changeDetectorRef.markForCheck(); + this.dataService + .fetchPortfolioHoldings() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(({ holdings }) => { + this.holdings = holdings + .filter(({ assetSubClass }) => { + return !['CASH'].includes(assetSubClass); + }) + .sort((a, b) => { + return a.name?.localeCompare(b.name); + }); + this.setFilterFormValues(); + + if (this.hasPermissionToChangeFilters) { + this.filterForm.enable({ emitEvent: false }); + } + + this.changeDetectorRef.markForCheck(); + }); } public onApplyFilters() { @@ -499,22 +509,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { ); } - private initializeFilterForm() { - this.dataService - .fetchPortfolioHoldings() - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ holdings }) => { - this.holdings = holdings - .filter(({ assetSubClass }) => { - return !['CASH'].includes(assetSubClass); - }) - .sort((a, b) => { - return a.name?.localeCompare(b.name); - }); - this.setFilterFormValues(); - }); - } - private setFilterFormValues() { const dataSource = this.user?.settings?.[ 'filters.dataSource' diff --git a/libs/ui/src/lib/assistant/assistant.html b/libs/ui/src/lib/assistant/assistant.html index 228c9cc56..33b4db3ff 100644 --- a/libs/ui/src/lib/assistant/assistant.html +++ b/libs/ui/src/lib/assistant/assistant.html @@ -87,7 +87,7 @@