Skip to content

Commit

Permalink
chore: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jan 20, 2024
1 parent 8d60f83 commit f09927b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
4 changes: 3 additions & 1 deletion packages/abc/page-header/page-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
DestroyRef,
ElementRef,
Input,
OnChanges,
Expand Down Expand Up @@ -66,6 +67,7 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit {
private readonly titleSrv = inject(TitleService, { optional: true });
private readonly reuseSrv = inject(ReuseTabService, { optional: true });
private readonly directionality = inject(Directionality, { optional: true });
private readonly destroy$ = inject(DestroyRef);

@ViewChild('conTpl', { static: false }) private conTpl!: ElementRef;
@ViewChild('affix', { static: false }) private affix!: NzAffixComponent;
Expand Down Expand Up @@ -206,7 +208,7 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
4 changes: 3 additions & 1 deletion packages/abc/result/result.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
DestroyRef,
Input,
OnInit,
TemplateRef,
Expand Down Expand Up @@ -31,6 +32,7 @@ import { NzIconDirective } from 'ng-zorro-antd/icon';
export class ResultComponent implements OnInit {
private readonly cdr = inject(ChangeDetectorRef);
private readonly directionality = inject(Directionality, { optional: true });
private readonly destroy$ = inject(DestroyRef);

_type = '';
_icon = '';
Expand All @@ -57,7 +59,7 @@ export class ResultComponent implements OnInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
28 changes: 13 additions & 15 deletions packages/form/src/sf.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ import {
ChangeDetectorRef,
Component,
EventEmitter,
Inject,
Injector,
Input,
OnChanges,
OnDestroy,
OnInit,
Optional,
Output,
SimpleChange,
SimpleChanges,
TemplateRef,
ViewEncapsulation,
booleanAttribute
booleanAttribute,
inject
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { DomSanitizer } from '@angular/platform-browser';
import { merge, Observable, filter } from 'rxjs';

import { ACLService } from '@delon/acl';
import { AlainI18NService, ALAIN_I18N_TOKEN, DelonLocaleService, LocaleData } from '@delon/theme';
import { ALAIN_I18N_TOKEN, DelonLocaleService, LocaleData } from '@delon/theme';
import { AlainConfigService, AlainSFConfig } from '@delon/util/config';
import { deepCopy } from '@delon/util/other';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
Expand Down Expand Up @@ -78,6 +77,15 @@ export function useFactory(
encapsulation: ViewEncapsulation.None
})
export class SFComponent implements OnInit, OnChanges, OnDestroy {
private readonly formPropertyFactory = inject(FormPropertyFactory);
private readonly terminator = inject(TerminatorService);
private readonly dom = inject(DomSanitizer);
private readonly cdr = inject(ChangeDetectorRef);
private readonly localeSrv = inject(DelonLocaleService);
private readonly aclSrv = inject(ACLService, { optional: true });
private readonly i18nSrv = inject(ALAIN_I18N_TOKEN, { optional: true });
private readonly platform = inject(Platform);

private _renders = new Map<string, TemplateRef<void>>();
private _item!: Record<string, unknown>;
private _valid = true;
Expand Down Expand Up @@ -295,17 +303,7 @@ export class SFComponent implements OnInit, OnChanges, OnDestroy {
this.formSubmit.emit(this.value);
}

constructor(
private formPropertyFactory: FormPropertyFactory,
private terminator: TerminatorService,
private dom: DomSanitizer,
private cdr: ChangeDetectorRef,
private localeSrv: DelonLocaleService,
@Optional() private aclSrv: ACLService,
@Optional() @Inject(ALAIN_I18N_TOKEN) private i18nSrv: AlainI18NService,
cogSrv: AlainConfigService,
private platform: Platform
) {
constructor(cogSrv: AlainConfigService) {
this.options = mergeConfig(cogSrv);
this.liveValidate = this.options.liveValidate as boolean;
this.firstVisual = this.options.firstVisual as boolean;
Expand Down
4 changes: 3 additions & 1 deletion packages/theme/setting-drawer/setting-drawer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
DestroyRef,
inject,
Input,
isDevMode,
Expand Down Expand Up @@ -39,6 +40,7 @@ export class SettingDrawerComponent implements OnInit {
private readonly ngZone = inject(NgZone);
private readonly doc = inject(DOCUMENT);
private readonly directionality = inject(Directionality, { optional: true });
private readonly destroy$ = inject(DestroyRef);

@Input({ transform: booleanAttribute }) autoApplyColor = true;
@Input() compilingText = 'Compiling...';
Expand Down Expand Up @@ -71,7 +73,7 @@ export class SettingDrawerComponent implements OnInit {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down
4 changes: 3 additions & 1 deletion packages/theme/theme-btn/theme-btn.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
DestroyRef,
EventEmitter,
inject,
InjectionToken,
Expand Down Expand Up @@ -47,6 +48,7 @@ export class ThemeBtnComponent implements OnInit, OnDestroy {
private readonly configSrv = inject(AlainConfigService);
private readonly directionality = inject(Directionality, { optional: true });
private readonly cdr = inject(ChangeDetectorRef);
private readonly destroy$ = inject(DestroyRef);

private theme = 'default';
isDev = isDevMode();
Expand All @@ -63,7 +65,7 @@ export class ThemeBtnComponent implements OnInit, OnDestroy {

ngOnInit(): void {
this.dir = this.directionality?.value;
this.directionality?.change.pipe(takeUntilDestroyed()).subscribe((direction: Direction) => {
this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe((direction: Direction) => {
this.dir = direction;
this.cdr.detectChanges();
});
Expand Down

0 comments on commit f09927b

Please sign in to comment.