fix darktheme loading

This commit is contained in:
_Bastler 2021-03-29 14:59:22 +02:00
parent f76843a2e9
commit de7b2f507e
2 changed files with 17 additions and 12 deletions

View File

@ -49,22 +49,28 @@ export class AuthenticatedGuard implements CanActivate {
}
this.profileService.getAll(["locale", "darkTheme"]).toPromise().then((profileFields: any) => {
let reload = false;
this.profileService.getAll(["locale", "darkTheme"]).subscribe((profileFields: any) => {
let updateLocale = false;
let darktheme = 'false';
let updateTheme = false;
for(let profileField of profileFields) {
if(profileField.name == "darkTheme" && profileField.value != localStorage.getItem("bstly.darkTheme")) {
localStorage.setItem("bstly.darkTheme", profileField.value);
reload = true;
if(profileField.name == "darkTheme") {
darktheme = profileField.value;
} else if(profileField.name == "locale" && this.i18nService.locales.indexOf(profileField.value) != -1 && localStorage.getItem("bstly.locale") != profileField.value) {
if(this.i18nService.locale != profileField.value) {
localStorage.setItem("bstly.locale", profileField.value);
reload = true;
updateLocale = true;
}
}
}
if(reload) {
window.location.reload();
if(darktheme != localStorage.getItem("bstly.darkTheme")) {
localStorage.setItem("bstly.darkTheme", darktheme);
updateTheme = true;
}
if(updateLocale || updateTheme) {
window.location.reload();
}
})

View File

@ -150,12 +150,11 @@ export class ProfileFieldDialog {
}
booleanChange(profileField) {
if(profileField.value == 'false') {
profileField.value = 'true';
} else {
if(profileField.value == 'true') {
profileField.value = 'false';
} else {
profileField.value = 'true';
}
console.log(profileField);
}
}