From 384d18b2a600274ccaa327b546446659b74a6c6f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 16 Oct 2022 08:45:52 +0200 Subject: [PATCH] Feature/persist user language on url change (#1359) * Persist user language * Update changelog --- CHANGELOG.md | 6 ++++++ apps/client/src/app/core/auth.guard.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f7b1def9..8fc2cd50f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apps/client/src/app/core/auth.guard.ts b/apps/client/src/app/core/auth.guard.ts index 1087fa4a3..349d44fb4 100644 --- a/apps/client/src/app/core/auth.guard.ts +++ b/apps/client/src/app/core/auth.guard.ts @@ -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 (