mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4745] memory leak fixes (#4931)
* fix app-layout component * fix card-view component * fix cloud-layout service * code fixes * code fixes * even more fixes * even more fixes * lint fixes * test fixes * fix code * remove useless pipes * fix code owners * enable spellcheck for cloud components * update test * update test
This commit is contained in:
committed by
Eugenio Romano
parent
e2311ab045
commit
1abb9bfc89
@@ -25,12 +25,13 @@ import {
|
||||
} from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef, MatDialog, MatSlideToggleChange } from '@angular/material';
|
||||
import { FormGroup, FormControl } from '@angular/forms';
|
||||
import { Subscription, Observable, throwError } from 'rxjs';
|
||||
import { Observable, throwError, Subject } from 'rxjs';
|
||||
import {
|
||||
skip,
|
||||
distinctUntilChanged,
|
||||
mergeMap,
|
||||
catchError
|
||||
catchError,
|
||||
takeUntil
|
||||
} from 'rxjs/operators';
|
||||
import {
|
||||
SharedLinksApiService,
|
||||
@@ -52,7 +53,6 @@ import { ContentNodeShareSettings } from './content-node-share.settings';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
minDate = moment().add(1, 'd');
|
||||
sharedId: string;
|
||||
@@ -75,6 +75,8 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('dateTimePickerInput')
|
||||
dateTimePickerInput;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(
|
||||
private appConfigService: AppConfigService,
|
||||
private sharedLinksApiService: SharedLinksApiService,
|
||||
@@ -93,21 +95,20 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
this.form.controls['time'].disable();
|
||||
}
|
||||
|
||||
this.subscriptions.push(
|
||||
this.form.controls.time.valueChanges
|
||||
.pipe(
|
||||
skip(1),
|
||||
distinctUntilChanged(),
|
||||
mergeMap(
|
||||
(updates) => this.updateNode(updates),
|
||||
(formUpdates) => formUpdates
|
||||
),
|
||||
catchError((error) => {
|
||||
return throwError(error);
|
||||
})
|
||||
)
|
||||
.subscribe((updates) => this.updateEntryExpiryDate(updates))
|
||||
);
|
||||
this.form.controls.time.valueChanges
|
||||
.pipe(
|
||||
skip(1),
|
||||
distinctUntilChanged(),
|
||||
mergeMap(
|
||||
(updates) => this.updateNode(updates),
|
||||
(formUpdates) => formUpdates
|
||||
),
|
||||
catchError((error) => {
|
||||
return throwError(error);
|
||||
}),
|
||||
takeUntil(this.onDestroy$)
|
||||
)
|
||||
.subscribe(updates => this.updateEntryExpiryDate(updates));
|
||||
|
||||
if (this.data.node && this.data.node.entry) {
|
||||
this.fileName = this.data.node.entry.name;
|
||||
@@ -126,7 +127,8 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach((subscription) => subscription.unsubscribe);
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
removeShare() {
|
||||
|
@@ -15,19 +15,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Directive, Input, HostListener, OnChanges, NgZone } from '@angular/core';
|
||||
import { Directive, Input, HostListener, OnChanges, NgZone, OnDestroy } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { NodeEntry, Node } from '@alfresco/js-api';
|
||||
|
||||
import { ShareDialogComponent } from './content-node-share.dialog';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { Observable, from, Subject } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Directive({
|
||||
selector: '[adf-share]',
|
||||
exportAs: 'adfShare'
|
||||
})
|
||||
export class NodeSharedDirective implements OnChanges {
|
||||
export class NodeSharedDirective implements OnChanges, OnDestroy {
|
||||
|
||||
isFile: boolean = false;
|
||||
isShared: boolean = false;
|
||||
@@ -41,12 +42,7 @@ export class NodeSharedDirective implements OnChanges {
|
||||
@Input()
|
||||
baseShareUrl: string;
|
||||
|
||||
@HostListener('click')
|
||||
onClick() {
|
||||
if (this.node) {
|
||||
this.shareNode(this.node);
|
||||
}
|
||||
}
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog,
|
||||
@@ -54,6 +50,11 @@ export class NodeSharedDirective implements OnChanges {
|
||||
private alfrescoApiService: AlfrescoApiService) {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
shareNode(nodeEntry: NodeEntry) {
|
||||
if (nodeEntry && nodeEntry.entry && nodeEntry.entry.isFile) {
|
||||
// shared and favorite
|
||||
@@ -89,11 +90,20 @@ export class NodeSharedDirective implements OnChanges {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.zone.onStable.subscribe(() => {
|
||||
if (this.node && this.node.entry) {
|
||||
this.isFile = this.node.entry.isFile;
|
||||
this.isShared = this.node.entry.properties ? this.node.entry.properties['qshare:sharedId'] : false;
|
||||
}
|
||||
});
|
||||
this.zone.onStable
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(() => {
|
||||
if (this.node && this.node.entry) {
|
||||
this.isFile = this.node.entry.isFile;
|
||||
this.isShared = this.node.entry.properties ? this.node.entry.properties['qshare:sharedId'] : false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@HostListener('click')
|
||||
onClick() {
|
||||
if (this.node) {
|
||||
this.shareNode(this.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user