[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:
Denys Vuika
2019-07-16 15:56:00 +01:00
committed by Eugenio Romano
parent e2311ab045
commit 1abb9bfc89
98 changed files with 1581 additions and 1066 deletions

View File

@@ -23,9 +23,10 @@ import {
import { Pagination } from '@alfresco/js-api';
import { PaginatedComponent } from './paginated-component.interface';
import { PaginationComponentInterface } from './pagination-component.interface';
import { Subscription } from 'rxjs';
import { Subject } from 'rxjs';
import { PaginationModel } from '../models/pagination.model';
import { UserPreferencesService, UserPreferenceValues } from '../services/user-preferences.service';
import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'adf-pagination',
@@ -82,29 +83,32 @@ export class PaginationComponent implements OnInit, OnDestroy, PaginationCompone
@Output()
prevPage: EventEmitter<PaginationModel> = new EventEmitter<PaginationModel>();
private paginationSubscription: Subscription;
private onDestroy$ = new Subject<boolean>();
constructor(private cdr: ChangeDetectorRef, private userPreferencesService: UserPreferencesService) {
this.userPreferencesService.select(UserPreferenceValues.PaginationSize).subscribe((pagSize) => {
this.pagination.maxItems = pagSize;
});
}
ngOnInit() {
this.userPreferencesService
.select(UserPreferenceValues.PaginationSize)
.pipe(takeUntil(this.onDestroy$))
.subscribe(pagSize => this.pagination.maxItems = pagSize);
if (!this.supportedPageSizes) {
this.supportedPageSizes = this.userPreferencesService.supportedPageSizes;
}
if (this.target) {
this.paginationSubscription = this.target.pagination.subscribe((pagination: PaginationModel) => {
this.target.pagination
.pipe(takeUntil(this.onDestroy$))
.subscribe(pagination => {
if (pagination.count === 0 && !this.isFirstPage) {
this.goPrevious();
}
if (pagination.count === 0 && !this.isFirstPage) {
this.goPrevious();
}
this.pagination = pagination;
this.cdr.detectChanges();
});
this.pagination = pagination;
this.cdr.detectChanges();
});
}
if (!this.pagination) {
@@ -217,6 +221,11 @@ export class PaginationComponent implements OnInit, OnDestroy, PaginationCompone
});
}
ngOnDestroy() {
this.onDestroy$.next(true);
this.onDestroy$.complete();
}
handlePaginationEvent(action: string, params: PaginationModel) {
const {
NEXT_PAGE,
@@ -258,10 +267,4 @@ export class PaginationComponent implements OnInit, OnDestroy, PaginationCompone
this.target.updatePagination(params);
}
}
ngOnDestroy() {
if (this.paginationSubscription) {
this.paginationSubscription.unsubscribe();
}
}
}