mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
(demo shell) fix memory leak with search results
This commit is contained in:
@@ -15,11 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, Optional, ViewChild } from '@angular/core';
|
||||
import { Component, OnInit, Optional, ViewChild, OnDestroy } from '@angular/core';
|
||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||
import { NodePaging, Pagination } from 'alfresco-js-api';
|
||||
import { SearchComponent, SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||
import { UserPreferencesService, SearchService, SearchConfigurationService } from '@alfresco/adf-core';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
|
||||
@Component({
|
||||
selector: 'app-search-result-component',
|
||||
@@ -27,7 +28,7 @@ import { UserPreferencesService, SearchService, SearchConfigurationService } fro
|
||||
styleUrls: ['./search-result.component.scss'],
|
||||
providers: [SearchService]
|
||||
})
|
||||
export class SearchResultComponent implements OnInit {
|
||||
export class SearchResultComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild('searchResult')
|
||||
searchResult: SearchComponent;
|
||||
@@ -41,6 +42,8 @@ export class SearchResultComponent implements OnInit {
|
||||
|
||||
sorting = ['name', 'asc'];
|
||||
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
constructor(public router: Router,
|
||||
private preferences: UserPreferencesService,
|
||||
private queryBuilder: SearchQueryBuilderService,
|
||||
@@ -57,9 +60,11 @@ export class SearchResultComponent implements OnInit {
|
||||
|
||||
this.sorting = this.getSorting();
|
||||
|
||||
this.queryBuilder.updated.subscribe(() => {
|
||||
this.sorting = this.getSorting();
|
||||
});
|
||||
this.subscriptions.push(
|
||||
this.queryBuilder.updated.subscribe(() => {
|
||||
this.sorting = this.getSorting();
|
||||
})
|
||||
);
|
||||
|
||||
if (this.route) {
|
||||
this.route.params.forEach((params: Params) => {
|
||||
@@ -74,6 +79,11 @@ export class SearchResultComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => subscription.unsubscribe());
|
||||
this.subscriptions = [];
|
||||
}
|
||||
|
||||
onSearchResultLoaded(nodePaging: NodePaging) {
|
||||
this.resultNodePageList = nodePaging;
|
||||
this.pagination = {...nodePaging.list.pagination };
|
||||
|
Reference in New Issue
Block a user