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) => {
|
this.profileService.getAll(["locale", "darkTheme"]).subscribe((profileFields: any) => {
|
||||||
let reload = false;
|
let updateLocale = false;
|
||||||
|
let darktheme = 'false';
|
||||||
|
let updateTheme = false;
|
||||||
for(let profileField of profileFields) {
|
for(let profileField of profileFields) {
|
||||||
if(profileField.name == "darkTheme" && profileField.value != localStorage.getItem("bstly.darkTheme")) {
|
if(profileField.name == "darkTheme") {
|
||||||
localStorage.setItem("bstly.darkTheme", profileField.value);
|
darktheme = profileField.value;
|
||||||
reload = true;
|
|
||||||
} else if(profileField.name == "locale" && this.i18nService.locales.indexOf(profileField.value) != -1 && localStorage.getItem("bstly.locale") != 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) {
|
if(this.i18nService.locale != profileField.value) {
|
||||||
localStorage.setItem("bstly.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();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -150,12 +150,11 @@ export class ProfileFieldDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
booleanChange(profileField) {
|
booleanChange(profileField) {
|
||||||
if(profileField.value == 'false') {
|
if(profileField.value == 'true') {
|
||||||
profileField.value = 'true';
|
|
||||||
} else {
|
|
||||||
profileField.value = 'false';
|
profileField.value = 'false';
|
||||||
|
} else {
|
||||||
|
profileField.value = 'true';
|
||||||
}
|
}
|
||||||
console.log(profileField);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user