Browse Source
Feature/persist user language on url change (#1359)
* Persist user language
* Update changelog
pull/1360/head
Thomas Kaul
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
14 additions and
1 deletions
-
CHANGELOG.md
-
apps/client/src/app/core/auth.guard.ts
|
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. |
|
|
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
|
|
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
|
|
|
|
|
|
|
## Unreleased |
|
|
|
|
|
|
|
### Changed |
|
|
|
|
|
|
|
- Persisted the language on url change |
|
|
|
|
|
|
|
## 1.204.1 - 15.10.2022 |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
@ -5,6 +5,7 @@ import { |
|
|
|
Router, |
|
|
|
RouterStateSnapshot |
|
|
|
} from '@angular/router'; |
|
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
|
|
import { SettingsStorageService } from '@ghostfolio/client/services/settings-storage.service'; |
|
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
|
import { EMPTY } from 'rxjs'; |
|
|
@ -30,6 +31,7 @@ export class AuthGuard implements CanActivate { |
|
|
|
]; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private dataService: DataService, |
|
|
|
private router: Router, |
|
|
|
private settingsStorageService: SettingsStorageService, |
|
|
|
private userService: UserService |
|
|
@ -74,7 +76,12 @@ export class AuthGuard implements CanActivate { |
|
|
|
const userLanguage = user?.settings?.language; |
|
|
|
|
|
|
|
if (userLanguage && document.documentElement.lang !== userLanguage) { |
|
|
|
window.location.href = `../${userLanguage}`; |
|
|
|
this.dataService |
|
|
|
.putUserSetting({ language: userLanguage }) |
|
|
|
.subscribe(() => { |
|
|
|
this.userService.remove(); |
|
|
|
}); |
|
|
|
|
|
|
|
resolve(false); |
|
|
|
return; |
|
|
|
} else if ( |
|
|
|