mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Fix todo url (#18954)
* Fix todo url * Move searchParams * Update src/panels/todo/ha-panel-todo.ts * check if saved entity exists --------- Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
6d36b0e28c
commit
c9e6963387
@ -46,7 +46,10 @@ import { HuiErrorCard } from "../lovelace/cards/hui-error-card";
|
|||||||
import { createCardElement } from "../lovelace/create-element/create-card-element";
|
import { createCardElement } from "../lovelace/create-element/create-card-element";
|
||||||
import { LovelaceCard } from "../lovelace/types";
|
import { LovelaceCard } from "../lovelace/types";
|
||||||
import { navigate } from "../../common/navigate";
|
import { navigate } from "../../common/navigate";
|
||||||
import { createSearchParam } from "../../common/url/search-params";
|
import {
|
||||||
|
createSearchParam,
|
||||||
|
extractSearchParam,
|
||||||
|
} from "../../common/url/search-params";
|
||||||
import { constructUrlCurrentPath } from "../../common/url/construct-url";
|
import { constructUrlCurrentPath } from "../../common/url/construct-url";
|
||||||
|
|
||||||
@customElement("ha-panel-todo")
|
@customElement("ha-panel-todo")
|
||||||
@ -105,18 +108,21 @@ class PanelTodo extends LitElement {
|
|||||||
|
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated) {
|
||||||
this.hass.loadFragmentTranslation("lovelace");
|
this.hass.loadFragmentTranslation("lovelace");
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.hasUpdated && !this._entityId) {
|
const urlEntityId = extractSearchParam("entity_id");
|
||||||
|
if (urlEntityId) {
|
||||||
|
this._entityId = urlEntityId;
|
||||||
|
} else {
|
||||||
|
if (this._entityId && !(this._entityId in this.hass.states)) {
|
||||||
|
this._entityId = undefined;
|
||||||
|
}
|
||||||
|
if (!this._entityId) {
|
||||||
this._entityId = getTodoLists(this.hass)[0]?.entity_id;
|
this._entityId = getTodoLists(this.hass)[0]?.entity_id;
|
||||||
} else if (!this.hasUpdated) {
|
}
|
||||||
this._setupTodoElement();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProperties: PropertyValues): void {
|
if (changedProperties.has("_entityId") || !this.hasUpdated) {
|
||||||
super.updated(changedProperties);
|
|
||||||
if (changedProperties.has("_entityId")) {
|
|
||||||
this._setupTodoElement();
|
this._setupTodoElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user