mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
[ACS-8959] Introduce new takeUntilDestroyed
operator (#4237)
This commit is contained in:
committed by
GitHub
parent
dec6c41e5c
commit
adda597f15
@@ -27,10 +27,9 @@ import { IconComponent } from '@alfresco/adf-core';
|
||||
import { DynamicExtensionComponent } from '@alfresco/adf-extensions';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, DestroyRef, inject, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'aca-datatable-cell-badges',
|
||||
@@ -41,29 +40,24 @@ import { takeUntil } from 'rxjs/operators';
|
||||
imports: [CommonModule, TranslateModule, DynamicExtensionComponent, IconComponent],
|
||||
standalone: true
|
||||
})
|
||||
export class DatatableCellBadgesComponent implements OnInit, OnDestroy {
|
||||
export class DatatableCellBadgesComponent implements OnInit {
|
||||
@Input() node: NodeEntry;
|
||||
|
||||
badges: Badge[];
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private appExtensionService: AppExtensionService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.appExtensionService
|
||||
.getBadges(this.node)
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((badges) => {
|
||||
this.badges = badges;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onBadgeClick(badge: Badge) {
|
||||
if (badge.actions?.click) {
|
||||
this.appExtensionService.runActionById(badge.actions?.click, this.node);
|
||||
|
Reference in New Issue
Block a user