Commit message: Add Optional and use !! to include localization resources in ConfigStateService

pull/16033/head
Mahmut Gundogdu 3 years ago
parent ac78dc969b
commit b7f1b4ac05

@ -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<void>();
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,
}),
),
)

@ -63,7 +63,7 @@ export class CoreTestingModule {
},
{
provide: INCUDE_LOCALIZATION_RESOURCES_TOKEN,
useValue: false,
useValue: true,
},
provideRoutes(routes),
],

Loading…
Cancel
Save