Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(module:upload): ensure i18n$ is defined on unsubscribe #5971

Merged
merged 1 commit into from
Oct 27, 2020

Conversation

aitboudad
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix

What is the current behavior?

if the upload component is destroyed before the ngOnInit call, I got the following error:

Cannot read property 'unsubscribe' of undefined
at NzUploadComponent.ngOnDestroy 

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@zorro-bot
Copy link

zorro-bot bot commented Oct 25, 2020

This preview will be available after the AzureCI is passed.

@codecov
Copy link

codecov bot commented Oct 25, 2020

Codecov Report

Merging #5971 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5971      +/-   ##
==========================================
- Coverage   89.96%   89.96%   -0.01%     
==========================================
  Files         465      465              
  Lines       14047    14046       -1     
  Branches     2311     2308       -3     
==========================================
- Hits        12638    12636       -2     
- Misses        859      862       +3     
+ Partials      550      548       -2     
Impacted Files Coverage Δ
components/upload/upload.component.ts 98.29% <100.00%> (+0.02%) ⬆️
components/table/src/table/tbody.component.ts 85.71% <0.00%> (-14.29%) ⬇️
components/table/src/table/tr-measure.component.ts 86.36% <0.00%> (-13.64%) ⬇️
components/date-picker/picker.component.ts 89.47% <0.00%> (-1.10%) ⬇️
components/time-picker/time-holder.ts 94.73% <0.00%> (-1.06%) ⬇️
components/date-picker/date-picker.component.ts 92.30% <0.00%> (-0.06%) ⬇️
components/date-picker/lib/abstract-table.ts 89.58% <0.00%> (ø)
components/date-picker/inner-popup.component.ts 86.95% <0.00%> (ø)
...mponents/date-picker/date-range-popup.component.ts 91.86% <0.00%> (+0.14%) ⬆️
components/select/select.component.ts 87.54% <0.00%> (+0.42%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a00b69...5806f81. Read the comment docs.

Copy link
Member

@hsuanxyz hsuanxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, could you modify it like the following? Just like the other components.

import { takeUntil } from 'rxjs/operators';

class NzUploadComponent {
   private destroy$ = new Subject<void>();

  ngOnInit(): void {
    this.i18n.localeChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
      this.locale = this.i18n.getLocaleData('Upload');
      this.detectChangesList();
    });
  }

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

@aitboudad
Copy link
Contributor Author

done!

Copy link
Member

@hsuanxyz hsuanxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hsuanxyz hsuanxyz merged commit b067e7e into NG-ZORRO:master Oct 27, 2020
@aitboudad aitboudad deleted the patch-1 branch October 27, 2020 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants