mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix race condition when saving url config (#24687)
* Fix race condition when saving url config * use SubscribeMixin
This commit is contained in:
parent
fe17bb89eb
commit
4a166b6c23
@ -22,9 +22,10 @@ import { copyToClipboard } from "../../../common/util/copy-clipboard";
|
|||||||
import { showToast } from "../../../util/toast";
|
import { showToast } from "../../../util/toast";
|
||||||
import type { HaSwitch } from "../../../components/ha-switch";
|
import type { HaSwitch } from "../../../components/ha-switch";
|
||||||
import { obfuscateUrl } from "../../../util/url";
|
import { obfuscateUrl } from "../../../util/url";
|
||||||
|
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||||
|
|
||||||
@customElement("ha-config-url-form")
|
@customElement("ha-config-url-form")
|
||||||
class ConfigUrlForm extends LitElement {
|
class ConfigUrlForm extends SubscribeMixin(LitElement) {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@state() private _error?: string;
|
@state() private _error?: string;
|
||||||
@ -49,6 +50,15 @@ class ConfigUrlForm extends LitElement {
|
|||||||
|
|
||||||
@state() private _cloudChecked = false;
|
@state() private _cloudChecked = false;
|
||||||
|
|
||||||
|
protected hassSubscribe() {
|
||||||
|
return [
|
||||||
|
this.hass.connection.subscribeEvents(() => {
|
||||||
|
// update the data when the urls are updated in core
|
||||||
|
this._fetchUrls();
|
||||||
|
}, "core_config_updated"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
const canEdit = ["storage", "default"].includes(
|
const canEdit = ["storage", "default"].includes(
|
||||||
this.hass.config.config_source
|
this.hass.config.config_source
|
||||||
@ -361,7 +371,6 @@ class ConfigUrlForm extends LitElement {
|
|||||||
? this._internal_url || null
|
? this._internal_url || null
|
||||||
: null,
|
: null,
|
||||||
});
|
});
|
||||||
await this._fetchUrls();
|
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this._error = err.message || err;
|
this._error = err.message || err;
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user