Ensure current active dark modes gets used for manually set themes (#10307)

This commit is contained in:
Philip Allgaier 2021-10-18 22:09:21 +02:00 committed by GitHub
parent f1cb21e7fc
commit bdb3c04037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 58 deletions

View File

@ -113,12 +113,6 @@ export class HassioMain extends SupervisorBaseElement {
: this.hass.themes.default_theme);
themeSettings = this.hass.selectedTheme;
if (themeSettings?.dark === undefined) {
themeSettings = {
...this.hass.selectedTheme,
dark: this.hass.themes.darkMode,
};
}
} else {
themeName =
(this.hass.selectedTheme as unknown as string) ||

View File

@ -36,7 +36,15 @@ export const applyThemesOnElement = (
let cacheKey = selectedTheme;
let themeRules: Partial<ThemeVars> = {};
if (themeSettings) {
// If there is no explicitly desired dark mode provided, we automatically
// use the active one from hass.themes.
if (!themeSettings || themeSettings?.dark === undefined) {
themeSettings = {
...themeSettings,
dark: themes.darkMode,
};
}
if (themeSettings.dark) {
cacheKey = `${cacheKey}__dark`;
themeRules = { ...darkStyles };
@ -86,7 +94,6 @@ export const applyThemesOnElement = (
return;
}
}
}
// Custom theme logic (not relevant for default theme, since it would override
// the derived calculations from above)

View File

@ -91,12 +91,6 @@ class SupervisorErrorScreen extends LitElement {
: this.hass.themes.default_theme);
themeSettings = this.hass.selectedTheme;
if (themeName === "default" && themeSettings?.dark === undefined) {
themeSettings = {
...this.hass.selectedTheme,
dark: this.hass.themes.darkMode,
};
}
} else {
themeName =
(this.hass.selectedTheme as unknown as string) ||