Skip to content

Commit

Permalink
Merge pull request #20863 from abpframework/auto-merge/rel-8-3/3013
Browse files Browse the repository at this point in the history
Merge branch dev with rel-8.3
  • Loading branch information
maliming authored Sep 23, 2024
2 parents 397e018 + 6dc30fd commit ca4da16
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import compare from 'just-compare';
import { filter, take } from 'rxjs/operators';
import { Session } from '../models/session';
Expand All @@ -12,6 +13,7 @@ import { AbpLocalStorageService } from './local-storage.service';
})
export class SessionStateService {
private readonly store = new InternalStore({} as Session.State);
protected readonly document = inject(DOCUMENT);

private updateLocalStorage = () => {
this.localStorageService.setItem('abpSession', JSON.stringify(this.store.state));
Expand Down Expand Up @@ -47,9 +49,8 @@ export class SessionStateService {
if (lang.includes(';')) {
lang = lang.split(';')[0];
}
if (appLanguage !== lang) {
this.setLanguage(lang);
}

this.setLanguage(lang);
});
}

Expand Down Expand Up @@ -84,9 +85,15 @@ export class SessionStateService {
}

setLanguage(language: string) {
if (language === this.store.state.language) return;
const currentLanguage = this.store.state.language;

if (language !== currentLanguage) {
this.store.patch({ language });
}

this.store.patch({ language });
document.documentElement.setAttribute('lang', language);
const currentAttribute = this.document.documentElement.getAttribute('lang');
if (language !== currentAttribute) {
this.document.documentElement.setAttribute('lang', language);
}
}
}

0 comments on commit ca4da16

Please sign in to comment.