From 078977de66caad0402febc19a7d7f6de2a0889f6 Mon Sep 17 00:00:00 2001 From: Kenrick Tandrian <60643640+KenTandrian@users.noreply.github.com> Date: Sun, 5 Apr 2026 09:35:39 +0000 Subject: [PATCH] fix(client): prevent memory leak --- ...reate-or-update-access-dialog.component.ts | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts index 50c6db4af..06cfa7a84 100644 --- a/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts +++ b/apps/client/src/app/components/user-account-access/create-or-update-access-dialog/create-or-update-access-dialog.component.ts @@ -83,22 +83,25 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { ] }); - this.accessForm.get('type')?.valueChanges.subscribe((accessType) => { - const granteeUserIdControl = this.accessForm.get('granteeUserId'); - const permissionsControl = this.accessForm.get('permissions'); - - if (accessType === 'PRIVATE') { - granteeUserIdControl?.setValidators(Validators.required); - } else { - granteeUserIdControl?.clearValidators(); - granteeUserIdControl?.setValue(null); - permissionsControl?.setValue(this.data.access.permissions[0]); - } - - granteeUserIdControl?.updateValueAndValidity(); - - this.changeDetectorRef.markForCheck(); - }); + this.accessForm + .get('type') + ?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((accessType) => { + const granteeUserIdControl = this.accessForm.get('granteeUserId'); + const permissionsControl = this.accessForm.get('permissions'); + + if (accessType === 'PRIVATE') { + granteeUserIdControl?.setValidators(Validators.required); + } else { + granteeUserIdControl?.clearValidators(); + granteeUserIdControl?.setValue(null); + permissionsControl?.setValue(this.data.access.permissions[0]); + } + + granteeUserIdControl?.updateValueAndValidity(); + + this.changeDetectorRef.markForCheck(); + }); } public onCancel() {