mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 13:37:47 +00:00
Add shouldUpdate
This commit is contained in:
parent
b766f2f337
commit
d3e2cc9128
@ -7,7 +7,7 @@ import {
|
|||||||
mdiClose,
|
mdiClose,
|
||||||
mdiInformationOutline,
|
mdiInformationOutline,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { css, html, LitElement } from "lit";
|
import { css, html, LitElement, PropertyValues } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
@ -47,6 +47,18 @@ class HaAlert extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public rtl = false;
|
@property({ type: Boolean }) public rtl = false;
|
||||||
|
|
||||||
|
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||||
|
if (changedProps.size !== 1 || !changedProps.has("hass")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldHass = changedProps.get("hass") as HomeAssistant;
|
||||||
|
if (!oldHass || !this.hass) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.hass.language !== oldHass.language;
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
|
Loading…
x
Reference in New Issue
Block a user