Only set tip once (#11853)

This commit is contained in:
Joakim Sørensen 2022-02-25 17:03:55 +01:00 committed by GitHub
parent 91e4557625
commit 4031009c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,7 @@ import {
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, property } from "lit/decorators";
import { customElement, property, state } from "lit/decorators";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import "../../../components/ha-card";
import "../../../components/ha-icon-next";
@ -118,6 +118,8 @@ class HaConfigDashboard extends LitElement {
@property() public showAdvanced!: boolean;
@state() private _tip?: string;
private _notifyUpdates = false;
protected render(): TemplateResult {
@ -204,7 +206,7 @@ class HaConfigDashboard extends LitElement {
<div class="tips">
<ha-svg-icon .path=${mdiLightbulbOutline}></ha-svg-icon>
<span class="tip-word">Tip!</span>
<span class="text">${randomTip(this.hass)}</span>
<span class="text">${this._tip}</span>
</div>
</ha-config-section>
</ha-app-layout>
@ -214,6 +216,10 @@ class HaConfigDashboard extends LitElement {
protected override updated(changedProps: PropertyValues): void {
super.updated(changedProps);
if (!this._tip && changedProps.has("hass")) {
this._tip = randomTip(this.hass);
}
if (!changedProps.has("supervisorUpdates") || !this._notifyUpdates) {
return;
}