From f400f459c83e4d0454d7565a9121040adf50c93a Mon Sep 17 00:00:00 2001 From: Erwin-N Date: Sat, 21 Mar 2026 21:08:35 +0100 Subject: [PATCH] Eliminate OnDestroy lifecycle hook from user account registration dialog component #6616 --- ...r-account-registration-dialog.component.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/apps/client/src/app/pages/register/user-account-registration-dialog/user-account-registration-dialog.component.ts b/apps/client/src/app/pages/register/user-account-registration-dialog/user-account-registration-dialog.component.ts index 4cc0f52f8..9a9ccc59d 100644 --- a/apps/client/src/app/pages/register/user-account-registration-dialog/user-account-registration-dialog.component.ts +++ b/apps/client/src/app/pages/register/user-account-registration-dialog/user-account-registration-dialog.component.ts @@ -9,9 +9,10 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA, Inject, - OnDestroy, + DestroyRef, ViewChild } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatCheckboxModule } from '@angular/material/checkbox'; @@ -27,8 +28,6 @@ import { checkmarkOutline, copyOutline } from 'ionicons/icons'; -import { Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; import { UserAccountRegistrationDialogParams } from './interfaces/interfaces'; @@ -53,7 +52,7 @@ import { UserAccountRegistrationDialogParams } from './interfaces/interfaces'; styleUrls: ['./user-account-registration-dialog.scss'], templateUrl: 'user-account-registration-dialog.html' }) -export class GfUserAccountRegistrationDialogComponent implements OnDestroy { +export class GfUserAccountRegistrationDialogComponent { @ViewChild(MatStepper) stepper!: MatStepper; public accessToken: string; @@ -64,12 +63,11 @@ export class GfUserAccountRegistrationDialogComponent implements OnDestroy { public routerLinkAboutTermsOfService = publicRoutes.about.subRoutes.termsOfService.routerLink; - private unsubscribeSubject = new Subject(); - public constructor( private changeDetectorRef: ChangeDetectorRef, @Inject(MAT_DIALOG_DATA) public data: UserAccountRegistrationDialogParams, - private dataService: DataService + private dataService: DataService, + private destroyRef: DestroyRef ) { addIcons({ arrowForwardOutline, checkmarkOutline, copyOutline }); } @@ -77,7 +75,7 @@ export class GfUserAccountRegistrationDialogComponent implements OnDestroy { public createAccount() { this.dataService .postUser() - .pipe(takeUntil(this.unsubscribeSubject)) + .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(({ accessToken, authToken, role }) => { this.accessToken = accessToken; this.authToken = authToken; @@ -96,9 +94,4 @@ export class GfUserAccountRegistrationDialogComponent implements OnDestroy { public onChangeDislaimerChecked() { this.isDisclaimerChecked = !this.isDisclaimerChecked; } - - public ngOnDestroy() { - this.unsubscribeSubject.next(); - this.unsubscribeSubject.complete(); - } }