Re-apply theme if backend theme changes (#3471)

This commit is contained in:
Paulus Schoutsen 2019-08-10 11:38:39 -07:00 committed by GitHub
parent 47d6bb69b0
commit ef3892de92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,6 +184,7 @@ export class HUIView extends LitElement {
protected updated(changedProperties: PropertyValues): void {
super.updated(changedProperties);
const hass = this.hass!;
const lovelace = this.lovelace!;
if (lovelace.editMode && !editCodeLoaded) {
@ -191,6 +192,7 @@ export class HUIView extends LitElement {
import(/* webpackChunkName: "hui-view-editable" */ "./hui-view-editable");
}
const hassChanged = changedProperties.has("hass");
let editModeChanged = false;
let configChanged = false;
@ -205,21 +207,38 @@ export class HUIView extends LitElement {
if (configChanged) {
this._createBadges(lovelace.config.views[this.index!]);
} else if (changedProperties.has("hass")) {
} else if (hassChanged) {
this._badges.forEach((badge) => {
const { element, entityId } = badge;
element.hass = this.hass!;
element.state = this.hass!.states[entityId];
element.hass = hass;
element.state = hass.states[entityId];
});
}
if (configChanged || editModeChanged || changedProperties.has("columns")) {
this._createCards(lovelace.config.views[this.index!]);
} else if (changedProperties.has("hass")) {
} else if (hassChanged) {
this._cards.forEach((element) => {
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 {
@ -311,8 +330,6 @@ export class HUIView extends LitElement {
});
this._cards = elements;
applyThemesOnElement(root, this.hass!.themes, config.theme);
}
private _rebuildCard(