Browse Source

refactor: eliminate OnDestroy in OpenComponent (#6588)

pull/6591/head
Witheast 2 weeks ago
parent
commit
9418027fa8
  1. 11
      apps/client/src/app/pages/open/open-page.component.ts

11
apps/client/src/app/pages/open/open-page.component.ts

@ -7,7 +7,8 @@ import {
ChangeDetectorRef, ChangeDetectorRef,
Component, Component,
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
OnInit inject,
DestroyRef
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MatCardModule } from '@angular/material/card'; import { MatCardModule } from '@angular/material/card';
@ -20,10 +21,12 @@ import { MatCardModule } from '@angular/material/card';
styleUrls: ['./open-page.scss'], styleUrls: ['./open-page.scss'],
templateUrl: './open-page.html' templateUrl: './open-page.html'
}) })
export class GfOpenPageComponent implements OnInit { export class GfOpenPageComponent {
public statistics: Statistics; public statistics: Statistics;
public user: User; public user: User;
private destroyRef = inject(DestroyRef);
public constructor( public constructor(
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService, private dataService: DataService,
@ -34,7 +37,7 @@ export class GfOpenPageComponent implements OnInit {
this.statistics = statistics; this.statistics = statistics;
this.userService.stateChanged this.userService.stateChanged
.pipe(takeUntilDestroyed()) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((state) => { .subscribe((state) => {
if (state?.user) { if (state?.user) {
this.user = state.user; this.user = state.user;
@ -43,6 +46,4 @@ export class GfOpenPageComponent implements OnInit {
} }
}); });
} }
public ngOnInit() {}
} }

Loading…
Cancel
Save