fix darktheme loading
This commit is contained in:
parent
f76843a2e9
commit
de7b2f507e
@ -49,21 +49,27 @@ 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) {
|
||||
if(darktheme != localStorage.getItem("bstly.darkTheme")) {
|
||||
localStorage.setItem("bstly.darkTheme", darktheme);
|
||||
updateTheme = true;
|
||||
}
|
||||
|
||||
if(updateLocale || updateTheme) {
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user