Browse Source

change switchMap operator to tap on config-state

pull/14562/head
Mahmut Gundogdu 3 years ago
parent
commit
e80e1295d7
  1. 14
      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

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

@ -1,6 +1,6 @@
import { Inject, Injectable } from '@angular/core'; import { Inject, Injectable } from '@angular/core';
import { Observable, Subject, of } from 'rxjs'; import { Observable, Subject, of } from 'rxjs';
import { map, switchMap, take } from 'rxjs/operators'; import { map, switchMap, take, tap } from 'rxjs/operators';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service'; import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
import { AbpApplicationLocalizationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-localization.service'; import { AbpApplicationLocalizationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-localization.service';
import { import {
@ -62,17 +62,15 @@ export class ConfigStateService {
return this.createOnUpdateStream(state => state).pipe(take(1)); return this.createOnUpdateStream(state => state).pipe(take(1));
} }
refreshLocalization(lang:string) { refreshLocalization(lang:string): Observable<null> {
if (this.includeLocalizationResources) { if (this.includeLocalizationResources) {
return this.refreshAppState(); return this.refreshAppState().pipe(map(()=> null));
} else { } else {
return this.getlocalizationResource(lang) return this.getlocalizationResource(lang)
.pipe( .pipe(
switchMap(result => { tap(result => this.store.patch({ localization: { ...this.store.state.localization, ...result } }))
this.store.patch({ localization: { ...this.store.state.localization, ...result } }); )
return of(null); .pipe(map(()=> null));
}),
);
} }
} }

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

@ -133,7 +133,7 @@ export class LocalizationService {
filter( filter(
lang => this.configState.getDeep('localization.currentCulture.cultureName') !== lang, lang => this.configState.getDeep('localization.currentCulture.cultureName') !== lang,
), ),
switchMap(lang => this.configState.refreshLocalization(lang).pipe(map(() => lang))), switchMap(lang => this.configState.refreshLocalization(lang).pipe(map(()=> lang))),
switchMap(lang => from(this.registerLocale(lang).then(() => lang))), switchMap(lang => from(this.registerLocale(lang).then(() => lang))),
) )
.subscribe(lang => this._languageChange$.next(lang)); .subscribe(lang => this._languageChange$.next(lang));

Loading…
Cancel
Save