From 8eae9a3279bd0121c1f37e8fa11b09ead05f9938 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 9 Apr 2026 18:03:37 +0200 Subject: [PATCH] Task/refactor user service to use takeUntilDestroyed and destroyRef (#6694) Refactor to takeUntilDestroyed and destroyRef --- apps/client/src/app/services/user/user.service.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/client/src/app/services/user/user.service.ts b/apps/client/src/app/services/user/user.service.ts index 44b63e056..e92eb6bd4 100644 --- a/apps/client/src/app/services/user/user.service.ts +++ b/apps/client/src/app/services/user/user.service.ts @@ -3,14 +3,15 @@ import { Filter, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { DestroyRef, Injectable } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatDialog } from '@angular/material/dialog'; import { ObservableStore } from '@codewithdan/observable-store'; import { parseISO } from 'date-fns'; import { DeviceDetectorService } from 'ngx-device-detector'; -import { Observable, Subject, of } from 'rxjs'; +import { Observable, of } from 'rxjs'; import { throwError } from 'rxjs'; -import { catchError, map, takeUntil } from 'rxjs/operators'; +import { catchError, map } from 'rxjs/operators'; import { SubscriptionInterstitialDialogParams } from '../../components/subscription-interstitial-dialog/interfaces/interfaces'; import { GfSubscriptionInterstitialDialogComponent } from '../../components/subscription-interstitial-dialog/subscription-interstitial-dialog.component'; @@ -22,9 +23,9 @@ import { UserStoreState } from './user-store.state'; }) export class UserService extends ObservableStore { private deviceType: string; - private unsubscribeSubject = new Subject(); public constructor( + private destroyRef: DestroyRef, private deviceService: DeviceDetectorService, private dialog: MatDialog, private http: HttpClient, @@ -163,7 +164,7 @@ export class UserService extends ObservableStore { dialogRef .afterClosed() - .pipe(takeUntil(this.unsubscribeSubject)) + .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(); }