mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +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 type { HaSwitch } from "../../../components/ha-switch";
|
||||
import { obfuscateUrl } from "../../../util/url";
|
||||
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||
|
||||
@customElement("ha-config-url-form")
|
||||
class ConfigUrlForm extends LitElement {
|
||||
class ConfigUrlForm extends SubscribeMixin(LitElement) {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@state() private _error?: string;
|
||||
@ -49,6 +50,15 @@ class ConfigUrlForm extends LitElement {
|
||||
|
||||
@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() {
|
||||
const canEdit = ["storage", "default"].includes(
|
||||
this.hass.config.config_source
|
||||
@ -361,7 +371,6 @@ class ConfigUrlForm extends LitElement {
|
||||
? this._internal_url || null
|
||||
: null,
|
||||
});
|
||||
await this._fetchUrls();
|
||||
} catch (err: any) {
|
||||
this._error = err.message || err;
|
||||
} finally {
|
||||
|
Loading…
x
Reference in New Issue
Block a user