From 8f9c31a5640130bb7c3cd4645a7bcd9906833475 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 3 Apr 2026 18:13:30 +0200 Subject: [PATCH] Task/eliminate OnDestroy lifecycle hook in user detail dialog component (#6664) Eliminate OnDestroy lifecycle hook --- .../user-detail-dialog.component.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts index 6f7f4ead6..fec2d4b06 100644 --- a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts +++ b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts @@ -7,10 +7,11 @@ import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA, + DestroyRef, Inject, - OnDestroy, OnInit } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog'; @@ -18,8 +19,8 @@ import { MatMenuModule } from '@angular/material/menu'; import { IonIcon } from '@ionic/angular/standalone'; import { addIcons } from 'ionicons'; import { ellipsisVertical } from 'ionicons/icons'; -import { EMPTY, Subject } from 'rxjs'; -import { catchError, takeUntil } from 'rxjs/operators'; +import { EMPTY } from 'rxjs'; +import { catchError } from 'rxjs/operators'; import { UserDetailDialogParams } from './interfaces/interfaces'; @@ -38,15 +39,14 @@ import { UserDetailDialogParams } from './interfaces/interfaces'; styleUrls: ['./user-detail-dialog.component.scss'], templateUrl: './user-detail-dialog.html' }) -export class GfUserDetailDialogComponent implements OnDestroy, OnInit { +export class GfUserDetailDialogComponent implements OnInit { public user: AdminUserResponse; - private unsubscribeSubject = new Subject(); - public constructor( private adminService: AdminService, private changeDetectorRef: ChangeDetectorRef, @Inject(MAT_DIALOG_DATA) public data: UserDetailDialogParams, + private destroyRef: DestroyRef, public dialogRef: MatDialogRef ) { addIcons({ @@ -58,7 +58,7 @@ export class GfUserDetailDialogComponent implements OnDestroy, OnInit { this.adminService .fetchUserById(this.data.userId) .pipe( - takeUntil(this.unsubscribeSubject), + takeUntilDestroyed(this.destroyRef), catchError(() => { this.dialogRef.close(); @@ -82,9 +82,4 @@ export class GfUserDetailDialogComponent implements OnDestroy, OnInit { public onClose() { this.dialogRef.close(); } - - public ngOnDestroy() { - this.unsubscribeSubject.next(); - this.unsubscribeSubject.complete(); - } }