diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts index ce772f5c5..abf8fb310 100644 --- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts +++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts @@ -242,7 +242,7 @@ export class CreateOrUpdateActivityDialog implements OnDestroy { if (this.activityForm.controls['searchSymbol'].invalid) { this.data.activity.SymbolProfile = null; } else if ( - !['ITEM', 'LIABILITY'].includes( + ['BUY', 'DIVIDEND', 'SELL'].includes( this.activityForm.controls['type'].value ) ) { @@ -412,8 +412,9 @@ export class CreateOrUpdateActivityDialog implements OnDestroy { fee: this.activityForm.controls['fee'].value, quantity: this.activityForm.controls['quantity'].value, symbol: - this.activityForm.controls['searchSymbol'].value.symbol === undefined || - isUUID(this.activityForm.controls['searchSymbol'].value.symbol) + this.activityForm.controls['searchSymbol'].value?.symbol === + undefined || + isUUID(this.activityForm.controls['searchSymbol'].value?.symbol) ? this.activityForm.controls['name'].value : this.activityForm.controls['searchSymbol'].value.symbol, tags: this.activityForm.controls['tags'].value, diff --git a/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts b/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts index 3f59f8e03..654a634ff 100644 --- a/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts +++ b/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts @@ -9,7 +9,7 @@ import { OnInit, ViewChild } from '@angular/core'; -import { FormControl, NgControl, Validators } from '@angular/forms'; +import { FormControl, NgControl } from '@angular/forms'; import { MatAutocomplete, MatAutocompleteSelectedEvent @@ -25,7 +25,8 @@ import { debounceTime, distinctUntilChanged, filter, - switchMap + switchMap, + takeUntil } from 'rxjs/operators'; import { AbstractMatFormField } from './abstract-mat-form-field'; @@ -80,11 +81,13 @@ export class SymbolAutocompleteComponent this.control.disable(); } - this.control.valueChanges.subscribe((_) => { - if (super.value) { - super.value.dataSource = null; - } - }); + this.control.valueChanges + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(() => { + if (super.value) { + super.value.dataSource = null; + } + }); this.control.valueChanges .pipe( @@ -93,6 +96,7 @@ export class SymbolAutocompleteComponent filter((query) => { return isString(query) && query.length > 1; }), + takeUntil(this.unsubscribeSubject), tap(() => { this.isLoading = true;