Browse Source

Task/eliminate OnDestroy lifecycle hook from activities table page (#6672)

Eliminate OnDestroy lifecycle hook
pull/6679/head
Erwin 3 days ago
committed by GitHub
parent
commit
1b26b6ced0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 20
      libs/ui/src/lib/activities-table/activities-table.component.ts

20
libs/ui/src/lib/activities-table/activities-table.component.ts

@ -20,9 +20,9 @@ import {
CUSTOM_ELEMENTS_SCHEMA,
ChangeDetectionStrategy,
Component,
DestroyRef,
EventEmitter,
Input,
OnDestroy,
OnInit,
Output,
ViewChild,
@ -30,6 +30,7 @@ import {
inject,
input
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
@ -68,7 +69,6 @@ import {
trashOutline
} from 'ionicons/icons';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { Subject, takeUntil } from 'rxjs';
import { GfActivityTypeComponent } from '../activity-type/activity-type.component';
import { GfEntityLogoComponent } from '../entity-logo/entity-logo.component';
@ -102,9 +102,7 @@ import { GfValueComponent } from '../value/value.component';
styleUrls: ['./activities-table.component.scss'],
templateUrl: './activities-table.component.html'
})
export class GfActivitiesTableComponent
implements AfterViewInit, OnDestroy, OnInit
{
export class GfActivitiesTableComponent implements AfterViewInit, OnInit {
@Input() baseCurrency: string;
@Input() deviceType: string;
@Input() hasActivities: boolean;
@ -198,9 +196,8 @@ export class GfActivitiesTableComponent
});
private readonly notificationService = inject(NotificationService);
private readonly unsubscribeSubject = new Subject<void>();
public constructor() {
public constructor(private destroyRef: DestroyRef) {
for (const type of Object.keys(ActivityType) as ActivityType[]) {
this.activityTypesTranslationMap.set(
ActivityType[type],
@ -228,14 +225,14 @@ export class GfActivitiesTableComponent
if (this.showCheckbox()) {
this.toggleAllRows();
this.selectedRows.changed
.pipe(takeUntil(this.unsubscribeSubject))
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((selectedRows) => {
this.selectedActivities.emit(selectedRows.source.selected);
});
}
this.typesFilter.valueChanges
.pipe(takeUntil(this.unsubscribeSubject))
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((types) => {
this.typesFilterChanged.emit(types ?? []);
});
@ -367,9 +364,4 @@ export class GfActivitiesTableComponent
this.selectedActivities.emit(this.selectedRows.selected);
}
public ngOnDestroy() {
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
}
}

Loading…
Cancel
Save