diff --git a/libs/ui/src/lib/assistant/assistant.component.ts b/libs/ui/src/lib/assistant/assistant.component.ts index 1c67e4fa2..aa8b9f022 100644 --- a/libs/ui/src/lib/assistant/assistant.component.ts +++ b/libs/ui/src/lib/assistant/assistant.component.ts @@ -11,17 +11,18 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + DestroyRef, ElementRef, HostListener, Input, OnChanges, - OnDestroy, OnInit, QueryList, ViewChild, ViewChildren, output } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -40,7 +41,7 @@ import { } from 'ionicons/icons'; import { isFunction } from 'lodash'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; -import { EMPTY, Observable, Subject, merge, of } from 'rxjs'; +import { EMPTY, Observable, merge, of } from 'rxjs'; import { catchError, debounceTime, @@ -48,7 +49,6 @@ import { map, scan, switchMap, - takeUntil, tap } from 'rxjs/operators'; @@ -84,7 +84,7 @@ import { styleUrls: ['./assistant.scss'], templateUrl: './assistant.html' }) -export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { +export class GfAssistantComponent implements OnChanges, OnInit { public static readonly SEARCH_RESULTS_DEFAULT_LIMIT = 5; @Input() deviceType: string; @@ -146,12 +146,12 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { private keyManager: FocusKeyManager; private preselectionTimeout: ReturnType; - private unsubscribeSubject = new Subject(); public constructor( private adminService: AdminService, private changeDetectorRef: ChangeDetectorRef, - private dataService: DataService + private dataService: DataService, + private destroyRef: DestroyRef ) { addIcons({ closeCircleOutline, closeOutline, searchOutline }); } @@ -333,7 +333,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { ) ); }), - takeUntil(this.unsubscribeSubject) + takeUntilDestroyed(this.destroyRef) ) .subscribe({ next: (searchResults) => { @@ -477,7 +477,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { this.dataService .fetchPortfolioHoldings() - .pipe(takeUntil(this.unsubscribeSubject)) + .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(({ holdings }) => { this.holdings = holdings .filter(({ assetSubClass }) => { @@ -556,9 +556,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { if (this.preselectionTimeout) { clearTimeout(this.preselectionTimeout); } - - this.unsubscribeSubject.next(); - this.unsubscribeSubject.complete(); } private getCurrentAssistantListItem() { @@ -643,7 +640,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { }; }); }), - takeUntil(this.unsubscribeSubject) + takeUntilDestroyed(this.destroyRef) ); } @@ -678,7 +675,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { } ); }), - takeUntil(this.unsubscribeSubject) + takeUntilDestroyed(this.destroyRef) ); } @@ -710,7 +707,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { } ); }), - takeUntil(this.unsubscribeSubject) + takeUntilDestroyed(this.destroyRef) ); }