Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Task/eliminate OnDestroy lifecycle hook from admin platform component (#6553)
Erwinf469bb9d363b
diff --git a/apps/client/src/app/components/admin-platform/admin-platform.component.ts b/apps/client/src/app/components/admin-platform/admin-platform.component.tsindex 2a04f86cc3..b8f2af7896 100644--- a/apps/client/src/app/components/admin-platform/admin-platform.component.ts+++ b/apps/client/src/app/components/admin-platform/admin-platform.component.ts@@ -11,11 +11,12 @@ import {ChangeDetectionStrategy,ChangeDetectorRef,Component,+ DestroyRef,Input,- OnDestroy,OnInit,ViewChild} from '@angular/core';+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';import { MatButtonModule } from '@angular/material/button';import { MatDialog } from '@angular/material/dialog';import { MatMenuModule } from '@angular/material/menu';@@ -32,7 +33,6 @@ import {} from 'ionicons/icons';import { get } from 'lodash';import { DeviceDetectorService } from 'ngx-device-detector';-import { Subject, takeUntil } from 'rxjs';import { GfCreateOrUpdatePlatformDialogComponent } from './create-or-update-platform-dialog/create-or-update-platform-dialog.component';import { CreateOrUpdatePlatformDialogParams } from './create-or-update-platform-dialog/interfaces/interfaces';@@ -53,7 +53,7 @@ import { CreateOrUpdatePlatformDialogParams } from './create-or-update-platform-styleUrls: ['./admin-platform.component.scss'],templateUrl: './admin-platform.component.html'})-export class GfAdminPlatformComponent implements OnDestroy, OnInit {+export class GfAdminPlatformComponent implements OnInit {@Input() locale = getLocale();@ViewChild(MatSort) sort: MatSort;@@ -63,12 +63,11 @@ export class GfAdminPlatformComponent implements OnDestroy, OnInit {public displayedColumns = ['name', 'url', 'accounts', 'actions'];public platforms: Platform[];- private unsubscribeSubject = new Subject<void>();-public constructor(private adminService: AdminService,private changeDetectorRef: ChangeDetectorRef,private dataService: DataService,+ private destroyRef: DestroyRef,private deviceService: DeviceDetectorService,private dialog: MatDialog,private notificationService: NotificationService,@@ -77,7 +76,7 @@ export class GfAdminPlatformComponent implements OnDestroy, OnInit {private userService: UserService) {this.route.queryParams- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe((params) => {if (params['createPlatformDialog']) {this.openCreatePlatformDialog();@@ -119,20 +118,15 @@ export class GfAdminPlatformComponent implements OnDestroy, OnInit {});}- public ngOnDestroy() {- this.unsubscribeSubject.next();- this.unsubscribeSubject.complete();- }-private deletePlatform(aId: string) {this.adminService.deletePlatform(aId)- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe({next: () => {this.userService.get(true)- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe();this.fetchPlatforms();@@ -143,7 +137,7 @@ export class GfAdminPlatformComponent implements OnDestroy, OnInit {private fetchPlatforms() {this.adminService.fetchPlatforms()- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe((platforms) => {this.platforms = platforms;@@ -175,17 +169,17 @@ export class GfAdminPlatformComponent implements OnDestroy, OnInit {dialogRef.afterClosed()- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe((platform: CreatePlatformDto | null) => {if (platform) {this.adminService.postPlatform(platform)- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe({next: () => {this.userService.get(true)- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe();this.fetchPlatforms();@@ -223,17 +217,17 @@ export class GfAdminPlatformComponent implements OnDestroy, OnInit {dialogRef.afterClosed()- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe((platform: UpdatePlatformDto | null) => {if (platform) {this.adminService.putPlatform(platform)- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe({next: () => {this.userService.get(true)- .pipe(takeUntil(this.unsubscribeSubject))+ .pipe(takeUntilDestroyed(this.destroyRef)).subscribe();this.fetchPlatforms();diff --git a/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.component.ts b/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.component.tsindex dfcf300c1f..0cfe026a4e 100644--- a/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.component.ts+++ b/apps/client/src/app/components/admin-platform/create-or-update-platform-dialog/create-or-update-platform-dialog.component.ts@@ -2,12 +2,7 @@ import { CreatePlatformDto, UpdatePlatformDto } from '@ghostfolio/common/dtos';import { validateObjectForForm } from '@ghostfolio/common/utils';import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo';-import {- ChangeDetectionStrategy,- Component,- Inject,- OnDestroy-} from '@angular/core';+import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';import {FormBuilder,FormGroup,@@ -23,7 +18,6 @@ import {} from '@angular/material/dialog';import { MatFormFieldModule } from '@angular/material/form-field';import { MatInputModule } from '@angular/material/input';-import { Subject } from 'rxjs';import { CreateOrUpdatePlatformDialogParams } from './interfaces/interfaces';@@ -43,11 +37,9 @@ import { CreateOrUpdatePlatformDialogParams } from './interfaces/interfaces';styleUrls: ['./create-or-update-platform-dialog.scss'],templateUrl: 'create-or-update-platform-dialog.html'})-export class GfCreateOrUpdatePlatformDialogComponent implements OnDestroy {+export class GfCreateOrUpdatePlatformDialogComponent {public platformForm: FormGroup;- private unsubscribeSubject = new Subject<void>();-public constructor(@Inject(MAT_DIALOG_DATA) public data: CreateOrUpdatePlatformDialogParams,public dialogRef: MatDialogRef<GfCreateOrUpdatePlatformDialogComponent>,@@ -90,9 +82,4 @@ export class GfCreateOrUpdatePlatformDialogComponent implements OnDestroy {console.error(error);}}-- public ngOnDestroy() {- this.unsubscribeSubject.next();- this.unsubscribeSubject.complete();- }}