Browse Source

get localization resources instead of refreshing app state

pull/19046/head
Sinan Öztürk 2 years ago
parent
commit
b5a3ee94ee
  1. 20
      npm/ng-packs/packages/core/src/lib/services/config-state.service.ts
  2. 2
      npm/ng-packs/packages/core/src/lib/services/localization.service.ts

20
npm/ng-packs/packages/core/src/lib/services/config-state.service.ts

@ -71,17 +71,13 @@ export class ConfigStateService {
}
refreshLocalization(lang: string): Observable<null> {
if (this.includeLocalizationResources) {
return this.refreshAppState().pipe(map(() => null));
} else {
return this.getlocalizationResource(lang)
.pipe(
tap(result =>
this.store.patch({ localization: { ...this.store.state.localization, ...result } }),
),
)
.pipe(map(() => null));
}
return this.getlocalizationResource(lang)
.pipe(
tap(result =>
this.store.patch({ localization: { ...this.store.state.localization, ...result } }),
),
)
.pipe(map(() => null));
}
getOne$<K extends keyof ApplicationConfigurationDto>(key: K) {
@ -145,7 +141,7 @@ export class ConfigStateService {
return keys.reduce((acc, key) => ({ ...acc, [key]: features.values[key] }), {});
}
getFeatures$(keys: string[]): Observable<{ [key: string]: string } | undefined> {
getFeatures$(keys: string[]): Observable<{ [key: string]: string; } | undefined> {
return this.store.sliceState(({ features }) => {
if (!features?.values) return;

2
npm/ng-packs/packages/core/src/lib/services/localization.service.ts

@ -134,7 +134,7 @@ export class LocalizationService {
filter(
lang => this.configState.getDeep('localization.currentCulture.cultureName') !== lang,
),
switchMap(lang => this.configState.refreshAppState().pipe(map(() => lang))),
switchMap(lang => this.configState.refreshLocalization(lang).pipe(map(() => lang))),
filter(Boolean),
switchMap(lang => from(this.registerLocale(lang).then(() => lang))),
)

Loading…
Cancel
Save