mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +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);
|
||||
|
@@ -23,17 +23,17 @@
|
||||
*/
|
||||
|
||||
import { NameColumnComponent, NodeNameTooltipPipe, NodesApiService } from '@alfresco/adf-content-services';
|
||||
import { ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { ChangeDetectorRef, Component, DestroyRef, ElementRef, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Actions, ofType } from '@ngrx/effects';
|
||||
import { Subject } from 'rxjs';
|
||||
import { filter, takeUntil } from 'rxjs/operators';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { NodeActionTypes } from '@alfresco/aca-shared/store';
|
||||
import { LockedByComponent, isLocked } from '@alfresco/aca-shared';
|
||||
import { isLocked, LockedByComponent } from '@alfresco/aca-shared';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { IconComponent } from '@alfresco/adf-core';
|
||||
import { DynamicExtensionComponent } from '@alfresco/adf-extensions';
|
||||
import { DatatableCellBadgesComponent } from '../datatable-cell-badges/datatable-cell-badges.component';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -54,12 +54,12 @@ import { DatatableCellBadgesComponent } from '../datatable-cell-badges/datatable
|
||||
class: 'adf-datatable-content-cell adf-datatable-link adf-name-column aca-custom-name-column'
|
||||
}
|
||||
})
|
||||
export class CustomNameColumnComponent extends NameColumnComponent implements OnInit, OnDestroy {
|
||||
private onDestroy$$ = new Subject<boolean>();
|
||||
|
||||
export class CustomNameColumnComponent extends NameColumnComponent implements OnInit {
|
||||
isFile: boolean;
|
||||
isFileWriteLocked: boolean;
|
||||
|
||||
private readonly destroy = inject(DestroyRef);
|
||||
|
||||
constructor(element: ElementRef, private cd: ChangeDetectorRef, private actions$: Actions, private nodesService: NodesApiService) {
|
||||
super(element, nodesService);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export class CustomNameColumnComponent extends NameColumnComponent implements On
|
||||
this.isFile = this.node?.entry && !this.node.entry.isFolder;
|
||||
this.isFileWriteLocked = isLocked(this.node);
|
||||
|
||||
this.nodesService.nodeUpdated.pipe(takeUntil(this.onDestroy$$)).subscribe((node: any) => {
|
||||
this.nodesService.nodeUpdated.pipe(takeUntilDestroyed(this.destroy)).subscribe((node: any) => {
|
||||
const row = this.context.row;
|
||||
if (row) {
|
||||
const { entry } = row.node;
|
||||
@@ -91,7 +91,7 @@ export class CustomNameColumnComponent extends NameColumnComponent implements On
|
||||
.pipe(
|
||||
ofType<any>(NodeActionTypes.EditOffline),
|
||||
filter((val) => this.node.entry.id === val.payload.entry.id),
|
||||
takeUntil(this.onDestroy$$)
|
||||
takeUntilDestroyed(this.destroy)
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.isFileWriteLocked = isLocked(this.node);
|
||||
@@ -103,9 +103,4 @@ export class CustomNameColumnComponent extends NameColumnComponent implements On
|
||||
event.stopPropagation();
|
||||
this.onClick();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$$.next(true);
|
||||
this.onDestroy$$.complete();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user