fix: listen to current lang instead of change in document-dir

pull/11450/head
bnymncoskuner 3 years ago
parent 8fcfa3b430
commit 0fc0fb8345

@ -27,7 +27,11 @@ export class LocalizationService {
* Returns currently selected language
*/
get currentLang(): string {
return this.latestLang || this.sessionState.getLanguage();
return this.latestLang;
}
get currentLang$(): Observable<string> {
return this.sessionState.getLanguage$();
}
get languageChange$(): Observable<string> {

@ -1,7 +1,7 @@
import { getLocaleDirection, LocalizationService } from '@abp/ng.core';
import { Injectable, Injector } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { LocaleDirection } from '../models/common';
@Injectable()
@ -14,17 +14,11 @@ export class DocumentDirHandlerService {
private listenToLanguageChanges() {
const l10n = this.injector.get(LocalizationService);
// will always listen, no need to unsubscribe
l10n.languageChange$
.pipe(
startWith(l10n.currentLang),
map(locale => getLocaleDirection(locale)),
)
.subscribe(dir => {
this.dir.next(dir);
this.setBodyDir(dir);
});
l10n.currentLang$.pipe(map(locale => getLocaleDirection(locale))).subscribe(dir => {
this.dir.next(dir);
this.setBodyDir(dir);
});
}
private setBodyDir(dir: LocaleDirection) {

Loading…
Cancel
Save