mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 20:26:39 +00:00
Fix translation race condition? (#7885)
This commit is contained in:
parent
3e4955becd
commit
565724d201
@ -210,7 +210,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
this.__coreProgress = language;
|
||||
try {
|
||||
const result = await getTranslation(null, language);
|
||||
this._updateResources(result.language, result.data);
|
||||
await this._updateResources(result.language, result.data);
|
||||
} finally {
|
||||
this.__coreProgress = undefined;
|
||||
}
|
||||
@ -226,18 +226,26 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
// 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;
|
||||
|
||||
if (language !== (this.hass ?? this._pendingHass).language) {
|
||||
// the language was changed, abort
|
||||
return;
|
||||
}
|
||||
|
||||
const resources = {
|
||||
[language]: {
|
||||
...baseHass?.resources?.[language],
|
||||
...(this.hass ?? this._pendingHass)?.resources?.[language],
|
||||
...data,
|
||||
},
|
||||
};
|
||||
const changes: Partial<HomeAssistant> = { resources };
|
||||
if (this.hass && language === this.hass.language) {
|
||||
changes.localize = await computeLocalize(this, language, resources);
|
||||
const changes: Partial<HomeAssistant> = {
|
||||
resources,
|
||||
localize: await computeLocalize(this, language, resources),
|
||||
};
|
||||
|
||||
if (language === (this.hass ?? this._pendingHass).language) {
|
||||
this._updateHass(changes);
|
||||
}
|
||||
this._updateHass(changes);
|
||||
}
|
||||
|
||||
private _refetchCachedHassTranslations(
|
||||
|
Loading…
x
Reference in New Issue
Block a user