mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Fix weather card (#5966)
This commit is contained in:
parent
e4607735ff
commit
df3b70a533
@ -97,6 +97,14 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
this._config = config;
|
this._config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||||
|
return hasConfigOrEntityChanged(this, changedProps);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected firstUpdated(): void {
|
||||||
|
this._attachObserver();
|
||||||
|
}
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues): void {
|
protected updated(changedProps: PropertyValues): void {
|
||||||
super.updated(changedProps);
|
super.updated(changedProps);
|
||||||
if (!this._config || !this.hass) {
|
if (!this._config || !this.hass) {
|
||||||
@ -109,10 +117,10 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
| undefined;
|
| undefined;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!oldHass ||
|
(changedProps.has("hass") && !oldHass) ||
|
||||||
!oldConfig ||
|
(changedProps.has("_config") && !oldConfig) ||
|
||||||
oldHass.themes !== this.hass.themes ||
|
(changedProps.has("hass") && oldHass!.themes !== this.hass.themes) ||
|
||||||
oldConfig.theme !== this._config.theme
|
(changedProps.has("_config") && oldConfig!.theme !== this._config.theme)
|
||||||
) {
|
) {
|
||||||
applyThemesOnElement(this, this.hass.themes, this._config.theme);
|
applyThemesOnElement(this, this.hass.themes, this._config.theme);
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
@ -277,22 +285,15 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
|
||||||
return hasConfigOrEntityChanged(this, changedProps);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected firstUpdated(): void {
|
|
||||||
this._attachObserver();
|
|
||||||
}
|
|
||||||
|
|
||||||
private _handleAction(): void {
|
private _handleAction(): void {
|
||||||
fireEvent(this, "hass-more-info", { entityId: this._config!.entity });
|
fireEvent(this, "hass-more-info", { entityId: this._config!.entity });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _attachObserver(): Promise<void> {
|
private async _attachObserver(): Promise<void> {
|
||||||
await installResizeObserver();
|
if (!this._resizeObserver) {
|
||||||
this._resizeObserver = new ResizeObserver(this._debouncedMeasure);
|
await installResizeObserver();
|
||||||
|
this._resizeObserver = new ResizeObserver(this._debouncedMeasure);
|
||||||
|
}
|
||||||
const card = this.shadowRoot!.querySelector("ha-card");
|
const card = this.shadowRoot!.querySelector("ha-card");
|
||||||
// If we show an error or warning there is no ha-card
|
// If we show an error or warning there is no ha-card
|
||||||
if (!card) {
|
if (!card) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user