Make iterating ha-timeline efficient (#8721)

This commit is contained in:
Paulus Schoutsen 2021-03-25 14:59:21 -07:00 committed by GitHub
parent 40cf4c8d32
commit f229e4e12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import {
internalProperty, internalProperty,
LitElement, LitElement,
property, property,
PropertyValues,
TemplateResult, TemplateResult,
} from "lit-element"; } from "lit-element";
import { formatDateTimeWithSeconds } from "../../common/datetime/format_date_time"; import { formatDateTimeWithSeconds } from "../../common/datetime/format_date_time";
@ -449,7 +450,7 @@ export class HaAutomationTracer extends LitElement {
return html`${entries}`; return html`${entries}`;
} }
protected updated(props) { protected updated(props: PropertyValues) {
super.updated(props); super.updated(props);
// Pick first path when we load a new trace. // Pick first path when we load a new trace.
@ -463,6 +464,7 @@ export class HaAutomationTracer extends LitElement {
} }
} }
if (props.has("trace") || props.has("_selectedPath")) {
this.shadowRoot!.querySelectorAll<HaTimeline>( this.shadowRoot!.querySelectorAll<HaTimeline>(
"ha-timeline[data-path]" "ha-timeline[data-path]"
).forEach((el) => { ).forEach((el) => {
@ -486,6 +488,7 @@ export class HaAutomationTracer extends LitElement {
}); });
}); });
} }
}
static get styles(): CSSResult[] { static get styles(): CSSResult[] {
return [ return [