Merge pull request #577 from Alfresco/dev-mvitale-546-fix

OnDestroy call unsubscribe
This commit is contained in:
VitoAlbano 2016-08-15 15:13:16 +01:00 committed by GitHub
commit 192f629fd1

View File

@ -53,6 +53,9 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
private _isDialogMinimized: boolean = false; private _isDialogMinimized: boolean = false;
private listSubscription: any;
private counterSubscription: any;
constructor(private cd: ChangeDetectorRef, constructor(private cd: ChangeDetectorRef,
translate: AlfrescoTranslationService, translate: AlfrescoTranslationService,
private _uploaderService: UploadService) { private _uploaderService: UploadService) {
@ -61,7 +64,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
if (this._uploaderService.filesUpload$) { if (this._uploaderService.filesUpload$) {
this._uploaderService.filesUpload$.subscribe((fileList: FileModel[]) => { this.listSubscription = this._uploaderService.filesUpload$.subscribe((fileList: FileModel[]) => {
this.filesUploadingList = fileList; this.filesUploadingList = fileList;
if (this.filesUploadingList.length > 0) { if (this.filesUploadingList.length > 0) {
this.isDialogActive = true; this.isDialogActive = true;
@ -70,7 +73,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
}); });
} }
if (this._uploaderService.totalCompleted$) { if (this._uploaderService.totalCompleted$) {
this._uploaderService.totalCompleted$.subscribe((total: number) => { this.counterSubscription = this._uploaderService.totalCompleted$.subscribe((total: number) => {
this.totalCompleted = total; this.totalCompleted = total;
this.cd.detectChanges(); this.cd.detectChanges();
}); });
@ -92,6 +95,8 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
} }
ngOnDestroy() { ngOnDestroy() {
this.listSubscription.unsubscribe();
this.counterSubscription.unsubscribe();
this.cd.detach(); this.cd.detach();
} }
} }