mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Re-apply theme if backend theme changes (#3471)
This commit is contained in:
parent
47d6bb69b0
commit
ef3892de92
@ -184,6 +184,7 @@ export class HUIView extends LitElement {
|
|||||||
protected updated(changedProperties: PropertyValues): void {
|
protected updated(changedProperties: PropertyValues): void {
|
||||||
super.updated(changedProperties);
|
super.updated(changedProperties);
|
||||||
|
|
||||||
|
const hass = this.hass!;
|
||||||
const lovelace = this.lovelace!;
|
const lovelace = this.lovelace!;
|
||||||
|
|
||||||
if (lovelace.editMode && !editCodeLoaded) {
|
if (lovelace.editMode && !editCodeLoaded) {
|
||||||
@ -191,6 +192,7 @@ export class HUIView extends LitElement {
|
|||||||
import(/* webpackChunkName: "hui-view-editable" */ "./hui-view-editable");
|
import(/* webpackChunkName: "hui-view-editable" */ "./hui-view-editable");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hassChanged = changedProperties.has("hass");
|
||||||
let editModeChanged = false;
|
let editModeChanged = false;
|
||||||
let configChanged = false;
|
let configChanged = false;
|
||||||
|
|
||||||
@ -205,21 +207,38 @@ export class HUIView extends LitElement {
|
|||||||
|
|
||||||
if (configChanged) {
|
if (configChanged) {
|
||||||
this._createBadges(lovelace.config.views[this.index!]);
|
this._createBadges(lovelace.config.views[this.index!]);
|
||||||
} else if (changedProperties.has("hass")) {
|
} else if (hassChanged) {
|
||||||
this._badges.forEach((badge) => {
|
this._badges.forEach((badge) => {
|
||||||
const { element, entityId } = badge;
|
const { element, entityId } = badge;
|
||||||
element.hass = this.hass!;
|
element.hass = hass;
|
||||||
element.state = this.hass!.states[entityId];
|
element.state = hass.states[entityId];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configChanged || editModeChanged || changedProperties.has("columns")) {
|
if (configChanged || editModeChanged || changedProperties.has("columns")) {
|
||||||
this._createCards(lovelace.config.views[this.index!]);
|
this._createCards(lovelace.config.views[this.index!]);
|
||||||
} else if (changedProperties.has("hass")) {
|
} else if (hassChanged) {
|
||||||
this._cards.forEach((element) => {
|
this._cards.forEach((element) => {
|
||||||
element.hass = this.hass;
|
element.hass = this.hass;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const oldHass = changedProperties.get("hass") as this["hass"] | undefined;
|
||||||
|
|
||||||
|
if (
|
||||||
|
configChanged ||
|
||||||
|
editModeChanged ||
|
||||||
|
(hassChanged &&
|
||||||
|
oldHass &&
|
||||||
|
(hass.themes !== oldHass.themes ||
|
||||||
|
hass.selectedTheme !== oldHass.selectedTheme))
|
||||||
|
) {
|
||||||
|
applyThemesOnElement(
|
||||||
|
this,
|
||||||
|
hass.themes,
|
||||||
|
lovelace.config.views[this.index!].theme
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _addCard(): void {
|
private _addCard(): void {
|
||||||
@ -311,8 +330,6 @@ export class HUIView extends LitElement {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._cards = elements;
|
this._cards = elements;
|
||||||
|
|
||||||
applyThemesOnElement(root, this.hass!.themes, config.theme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _rebuildCard(
|
private _rebuildCard(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user