From f2963ecaa7b7a94310ff6bb633ddb31698ba8b20 Mon Sep 17 00:00:00 2001 From: Matej Gerek Date: Sun, 6 Oct 2024 19:44:41 +0200 Subject: [PATCH] Move user state init --- .../holding-detail-dialog.component.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts index 262dc9ead..ca367afba 100644 --- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts +++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts @@ -147,7 +147,15 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { ) {} public ngOnInit() { - const { tags } = this.user; + this.userService.stateChanged + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((state) => { + if (state?.user) { + this.user = state.user; + + this.changeDetectorRef.markForCheck(); + } + }); this.activityForm = this.formBuilder.group({ tags: [] @@ -158,6 +166,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { { id: this.data.symbol, type: 'SYMBOL' } ]; + const { tags } = this.user; this.tagsAvailable = tags.map((tag) => { return { ...tag, @@ -427,16 +436,6 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit { this.changeDetectorRef.markForCheck(); } ); - - this.userService.stateChanged - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe((state) => { - if (state?.user) { - this.user = state.user; - - this.changeDetectorRef.markForCheck(); - } - }); } public onAddTag(event: MatAutocompleteSelectedEvent) {