From 6da77e6417a3f85eb6dd533c5f2ce72ad2a40c02 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 2 Apr 2026 19:45:53 +0200 Subject: [PATCH] Task/eliminate OnDestroy lifecycle hook in pricing page component (#6657) Eliminate OnDestroy lifecycle hook --- .../pages/pricing/pricing-page.component.ts | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/apps/client/src/app/pages/pricing/pricing-page.component.ts b/apps/client/src/app/pages/pricing/pricing-page.component.ts index 831f0809c..08c561fc8 100644 --- a/apps/client/src/app/pages/pricing/pricing-page.component.ts +++ b/apps/client/src/app/pages/pricing/pricing-page.component.ts @@ -12,9 +12,10 @@ import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA, - OnDestroy, + DestroyRef, OnInit } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { MatTooltipModule } from '@angular/material/tooltip'; @@ -27,8 +28,8 @@ import { informationCircleOutline } from 'ionicons/icons'; import { StringValue } from 'ms'; -import { EMPTY, Subject } from 'rxjs'; -import { catchError, takeUntil } from 'rxjs/operators'; +import { EMPTY } from 'rxjs'; +import { catchError } from 'rxjs/operators'; @Component({ host: { class: 'page' }, @@ -46,7 +47,7 @@ import { catchError, takeUntil } from 'rxjs/operators'; styleUrls: ['./pricing-page.scss'], templateUrl: './pricing-page.html' }) -export class GfPricingPageComponent implements OnDestroy, OnInit { +export class GfPricingPageComponent implements OnInit { public baseCurrency: string; public coupon: number; public couponId: string; @@ -92,11 +93,10 @@ export class GfPricingPageComponent implements OnDestroy, OnInit { public routerLinkRegister = publicRoutes.register.routerLink; public user: User; - private unsubscribeSubject = new Subject(); - public constructor( private changeDetectorRef: ChangeDetectorRef, private dataService: DataService, + private destroyRef: DestroyRef, private notificationService: NotificationService, private userService: UserService ) { @@ -124,7 +124,7 @@ export class GfPricingPageComponent implements OnDestroy, OnInit { this.price = subscriptionOffer?.price; this.userService.stateChanged - .pipe(takeUntil(this.unsubscribeSubject)) + .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((state) => { if (state?.user) { this.user = state.user; @@ -161,15 +161,10 @@ export class GfPricingPageComponent implements OnDestroy, OnInit { return EMPTY; }), - takeUntil(this.unsubscribeSubject) + takeUntilDestroyed(this.destroyRef) ) .subscribe(({ sessionUrl }) => { window.location.href = sessionUrl; }); } - - public ngOnDestroy() { - this.unsubscribeSubject.next(); - this.unsubscribeSubject.complete(); - } }