Skip to content

Commit

Permalink
fix(module:upload): ensure i18n$ is defined on unsubscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
aitboudad committed Oct 26, 2020
1 parent 4a00b69 commit 5806f81
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions components/upload/upload.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
ViewEncapsulation
} from '@angular/core';
import { BooleanInput, NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
import { Observable, of, Subscription } from 'rxjs';
import { filter } from 'rxjs/operators';
import { Observable, of, Subject, Subscription } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators';

import { InputBoolean, InputNumber, toBoolean } from 'ng-zorro-antd/core/util';
import { NzI18nService, NzUploadI18nInterface } from 'ng-zorro-antd/i18n';
Expand Down Expand Up @@ -60,7 +60,7 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy {
static ngAcceptInputType_nzShowButton: BooleanInput;
static ngAcceptInputType_nzWithCredentials: BooleanInput;

private i18n$!: Subscription;
private destroy$ = new Subject<void>();
@ViewChild('uploadComp', { static: false }) uploadComp!: NzUploadBtnComponent;
@ViewChild('listComp', { static: false }) listComp!: NzUploadListComponent;

Expand Down Expand Up @@ -321,7 +321,7 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy {
// #endregion

ngOnInit(): void {
this.i18n$ = this.i18n.localeChange.subscribe(() => {
this.i18n.localeChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
this.locale = this.i18n.getLocaleData('Upload');
this.detectChangesList();
});
Expand All @@ -332,6 +332,7 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy {
}

ngOnDestroy(): void {
this.i18n$.unsubscribe();
this.destroy$.next();
this.destroy$.complete();
}
}

0 comments on commit 5806f81

Please sign in to comment.