From b5a3ee94eecb779c79ed56d8904bb430431a9b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sinan=20=C3=96zt=C3=BCrk?= Date: Thu, 15 Feb 2024 13:55:25 +0300 Subject: [PATCH] get localization resources instead of refreshing app state --- .../src/lib/services/config-state.service.ts | 20 ++++++++----------- .../src/lib/services/localization.service.ts | 2 +- 2 files changed, 9 insertions(+), 13 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 103aad6da2..25a474ce84 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 @@ -71,17 +71,13 @@ export class ConfigStateService { } refreshLocalization(lang: string): Observable { - 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$(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; diff --git a/npm/ng-packs/packages/core/src/lib/services/localization.service.ts b/npm/ng-packs/packages/core/src/lib/services/localization.service.ts index 8305c35c9c..6a6fbdbc46 100644 --- a/npm/ng-packs/packages/core/src/lib/services/localization.service.ts +++ b/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))), )