mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Fix race condition in translation loading (#7597)
This commit is contained in:
parent
9a3a7c28f4
commit
461b86a04b
@ -221,9 +221,15 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
// loaded resources. This merges the new data on top of the old data for
|
// loaded resources. This merges the new data on top of the old data for
|
||||||
// this language, so that the full translation set can be loaded across
|
// this language, so that the full translation set can be loaded across
|
||||||
// multiple fragments.
|
// multiple fragments.
|
||||||
|
//
|
||||||
|
// Beware of a subtle race condition: it is possible to get here twice
|
||||||
|
// before this.hass is even created. In this case our base state comes
|
||||||
|
// from this._pendingHass instead. Otherwise the first set of strings is
|
||||||
|
// overwritten when we call _updateHass the second time!
|
||||||
|
const baseHass = this.hass ?? this._pendingHass;
|
||||||
const resources = {
|
const resources = {
|
||||||
[language]: {
|
[language]: {
|
||||||
...this.hass?.resources?.[language],
|
...baseHass?.resources?.[language],
|
||||||
...data,
|
...data,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user