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.
|
* 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 { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
import { NodePaging, Pagination } from 'alfresco-js-api';
|
import { NodePaging, Pagination } from 'alfresco-js-api';
|
||||||
import { SearchComponent, SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
import { SearchComponent, SearchQueryBuilderService } from '@alfresco/adf-content-services';
|
||||||
import { UserPreferencesService, SearchService, SearchConfigurationService } from '@alfresco/adf-core';
|
import { UserPreferencesService, SearchService, SearchConfigurationService } from '@alfresco/adf-core';
|
||||||
|
import { Subscription } from 'rxjs/Subscription';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-search-result-component',
|
selector: 'app-search-result-component',
|
||||||
@@ -27,7 +28,7 @@ import { UserPreferencesService, SearchService, SearchConfigurationService } fro
|
|||||||
styleUrls: ['./search-result.component.scss'],
|
styleUrls: ['./search-result.component.scss'],
|
||||||
providers: [SearchService]
|
providers: [SearchService]
|
||||||
})
|
})
|
||||||
export class SearchResultComponent implements OnInit {
|
export class SearchResultComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@ViewChild('searchResult')
|
@ViewChild('searchResult')
|
||||||
searchResult: SearchComponent;
|
searchResult: SearchComponent;
|
||||||
@@ -41,6 +42,8 @@ export class SearchResultComponent implements OnInit {
|
|||||||
|
|
||||||
sorting = ['name', 'asc'];
|
sorting = ['name', 'asc'];
|
||||||
|
|
||||||
|
private subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
constructor(public router: Router,
|
constructor(public router: Router,
|
||||||
private preferences: UserPreferencesService,
|
private preferences: UserPreferencesService,
|
||||||
private queryBuilder: SearchQueryBuilderService,
|
private queryBuilder: SearchQueryBuilderService,
|
||||||
@@ -57,9 +60,11 @@ export class SearchResultComponent implements OnInit {
|
|||||||
|
|
||||||
this.sorting = this.getSorting();
|
this.sorting = this.getSorting();
|
||||||
|
|
||||||
this.queryBuilder.updated.subscribe(() => {
|
this.subscriptions.push(
|
||||||
this.sorting = this.getSorting();
|
this.queryBuilder.updated.subscribe(() => {
|
||||||
});
|
this.sorting = this.getSorting();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
if (this.route) {
|
if (this.route) {
|
||||||
this.route.params.forEach((params: Params) => {
|
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) {
|
onSearchResultLoaded(nodePaging: NodePaging) {
|
||||||
this.resultNodePageList = nodePaging;
|
this.resultNodePageList = nodePaging;
|
||||||
this.pagination = {...nodePaging.list.pagination };
|
this.pagination = {...nodePaging.list.pagination };
|
||||||
|
Reference in New Issue
Block a user