From b7f1b4ac05db570f2446ce02c3351ad5b514ba11 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Tue, 21 Mar 2023 16:18:26 +0300 Subject: [PATCH 1/2] Commit message: Add Optional and use !! to include localization resources in ConfigStateService --- .../core/src/lib/services/config-state.service.ts | 15 +++++++++------ .../core/testing/src/lib/core-testing.module.ts | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts b/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts index e4475cd462..c245005ff7 100644 --- a/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/config-state.service.ts @@ -1,4 +1,4 @@ -import { inject, Injectable } from '@angular/core'; +import { Inject, Injectable, Optional } from '@angular/core'; import { Observable, Subject } from 'rxjs'; import { map, switchMap, take, tap } from 'rxjs/operators'; import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service'; @@ -15,9 +15,6 @@ import { InternalStore } from '../utils/internal-store-utils'; }) export class ConfigStateService { private readonly store = new InternalStore({} as ApplicationConfigurationDto); - private readonly includeLocalizationResources = inject(INCUDE_LOCALIZATION_RESOURCES_TOKEN); - private abpConfigService = inject(AbpApplicationConfigurationService); - private abpApplicationLocalizationService = inject(AbpApplicationLocalizationService); get createOnUpdateStream() { return this.store.sliceUpdate; @@ -25,7 +22,13 @@ export class ConfigStateService { private updateSubject = new Subject(); - constructor() { + constructor( + private abpConfigService: AbpApplicationConfigurationService, + private abpApplicationLocalizationService: AbpApplicationLocalizationService, + @Optional() + @Inject(INCUDE_LOCALIZATION_RESOURCES_TOKEN) + private readonly includeLocalizationResources: boolean | null, + ) { this.initUpdateStream(); } @@ -34,7 +37,7 @@ export class ConfigStateService { .pipe( switchMap(() => this.abpConfigService.get({ - includeLocalizationResources: this.includeLocalizationResources, + includeLocalizationResources: !!this.includeLocalizationResources, }), ), ) diff --git a/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts b/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts index 8aab44d44b..7ffeba2a9e 100644 --- a/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts +++ b/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts @@ -63,7 +63,7 @@ export class CoreTestingModule { }, { provide: INCUDE_LOCALIZATION_RESOURCES_TOKEN, - useValue: false, + useValue: true, }, provideRoutes(routes), ], From a6006a1135eb880ecfb620dcf5bc9796d0b35690 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Tue, 21 Mar 2023 17:21:57 +0300 Subject: [PATCH 2/2] Update core-testing.module.ts --- .../packages/core/testing/src/lib/core-testing.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts b/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts index 7ffeba2a9e..8aab44d44b 100644 --- a/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts +++ b/npm/ng-packs/packages/core/testing/src/lib/core-testing.module.ts @@ -63,7 +63,7 @@ export class CoreTestingModule { }, { provide: INCUDE_LOCALIZATION_RESOURCES_TOKEN, - useValue: true, + useValue: false, }, provideRoutes(routes), ],