mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 10:48:44 +00:00
Wait for translations before showing home and domain dashboards (#28556)
This commit is contained in:
@@ -37,8 +37,7 @@ class PanelClimate extends LitElement {
|
|||||||
super.willUpdate(changedProps);
|
super.willUpdate(changedProps);
|
||||||
// Initial setup
|
// Initial setup
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated) {
|
||||||
this.hass.loadFragmentTranslation("lovelace");
|
this._setup();
|
||||||
this._setLovelace();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +74,11 @@ class PanelClimate extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _setup() {
|
||||||
|
await this.hass.loadFragmentTranslation("lovelace");
|
||||||
|
this._setLovelace();
|
||||||
|
}
|
||||||
|
|
||||||
private _debounceRegistriesChanged = debounce(
|
private _debounceRegistriesChanged = debounce(
|
||||||
() => this._registriesChanged(),
|
() => this._registriesChanged(),
|
||||||
200
|
200
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import type { LovelaceDashboardStrategyConfig } from "../../data/lovelace/config
|
|||||||
import type { HomeAssistant, PanelInfo, Route } from "../../types";
|
import type { HomeAssistant, PanelInfo, Route } from "../../types";
|
||||||
import { showToast } from "../../util/toast";
|
import { showToast } from "../../util/toast";
|
||||||
import "../lovelace/hui-root";
|
import "../lovelace/hui-root";
|
||||||
import { generateLovelaceDashboardStrategy } from "../lovelace/strategies/get-strategy";
|
import { expandLovelaceConfigStrategies } from "../lovelace/strategies/get-strategy";
|
||||||
import type { Lovelace } from "../lovelace/types";
|
import type { Lovelace } from "../lovelace/types";
|
||||||
import { showEditHomeDialog } from "./dialogs/show-dialog-edit-home";
|
import { showEditHomeDialog } from "./dialogs/show-dialog-edit-home";
|
||||||
|
|
||||||
@@ -34,8 +34,7 @@ class PanelHome extends LitElement {
|
|||||||
super.willUpdate(changedProps);
|
super.willUpdate(changedProps);
|
||||||
// Initial setup
|
// Initial setup
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated) {
|
||||||
this.hass.loadFragmentTranslation("lovelace");
|
this._setup();
|
||||||
this._loadConfig();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +71,21 @@ class PanelHome extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _setup() {
|
||||||
|
try {
|
||||||
|
const [_, data] = await Promise.all([
|
||||||
|
this.hass.loadFragmentTranslation("lovelace"),
|
||||||
|
fetchFrontendSystemData(this.hass.connection, "home"),
|
||||||
|
]);
|
||||||
|
this._config = data || {};
|
||||||
|
} catch (err) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error("Failed to load favorites:", err);
|
||||||
|
this._config = {};
|
||||||
|
}
|
||||||
|
this._setLovelace();
|
||||||
|
}
|
||||||
|
|
||||||
private _debounceRegistriesChanged = debounce(
|
private _debounceRegistriesChanged = debounce(
|
||||||
() => this._registriesChanged(),
|
() => this._registriesChanged(),
|
||||||
200
|
200
|
||||||
@@ -97,18 +111,6 @@ class PanelHome extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _loadConfig() {
|
|
||||||
try {
|
|
||||||
const data = await fetchFrontendSystemData(this.hass.connection, "home");
|
|
||||||
this._config = data || {};
|
|
||||||
} catch (err) {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.error("Failed to load favorites:", err);
|
|
||||||
this._config = {};
|
|
||||||
}
|
|
||||||
this._setLovelace();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _setLovelace() {
|
private async _setLovelace() {
|
||||||
const strategyConfig: LovelaceDashboardStrategyConfig = {
|
const strategyConfig: LovelaceDashboardStrategyConfig = {
|
||||||
strategy: {
|
strategy: {
|
||||||
@@ -117,7 +119,7 @@ class PanelHome extends LitElement {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const config = await generateLovelaceDashboardStrategy(
|
const config = await expandLovelaceConfigStrategies(
|
||||||
strategyConfig,
|
strategyConfig,
|
||||||
this.hass
|
this.hass
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ class PanelLight extends LitElement {
|
|||||||
super.willUpdate(changedProps);
|
super.willUpdate(changedProps);
|
||||||
// Initial setup
|
// Initial setup
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated) {
|
||||||
this.hass.loadFragmentTranslation("lovelace");
|
this._setup();
|
||||||
this._setLovelace();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +74,11 @@ class PanelLight extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _setup() {
|
||||||
|
await this.hass.loadFragmentTranslation("lovelace");
|
||||||
|
this._setLovelace();
|
||||||
|
}
|
||||||
|
|
||||||
private _debounceRegistriesChanged = debounce(
|
private _debounceRegistriesChanged = debounce(
|
||||||
() => this._registriesChanged(),
|
() => this._registriesChanged(),
|
||||||
200
|
200
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ class PanelSecurity extends LitElement {
|
|||||||
super.willUpdate(changedProps);
|
super.willUpdate(changedProps);
|
||||||
// Initial setup
|
// Initial setup
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated) {
|
||||||
this.hass.loadFragmentTranslation("lovelace");
|
this._setup();
|
||||||
this._setLovelace();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +74,11 @@ class PanelSecurity extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _setup() {
|
||||||
|
await this.hass.loadFragmentTranslation("lovelace");
|
||||||
|
this._setLovelace();
|
||||||
|
}
|
||||||
|
|
||||||
private _debounceRegistriesChanged = debounce(
|
private _debounceRegistriesChanged = debounce(
|
||||||
() => this._registriesChanged(),
|
() => this._registriesChanged(),
|
||||||
200
|
200
|
||||||
|
|||||||
Reference in New Issue
Block a user