mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46: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 { LovelaceCard } from "../lovelace/types";
|
||||
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";
|
||||
|
||||
@customElement("ha-panel-todo")
|
||||
@ -105,18 +108,21 @@ class PanelTodo extends LitElement {
|
||||
|
||||
if (!this.hasUpdated) {
|
||||
this.hass.loadFragmentTranslation("lovelace");
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.hasUpdated && !this._entityId) {
|
||||
this._entityId = getTodoLists(this.hass)[0]?.entity_id;
|
||||
} else if (!this.hasUpdated) {
|
||||
this._setupTodoElement();
|
||||
}
|
||||
}
|
||||
|
||||
protected updated(changedProperties: PropertyValues): void {
|
||||
super.updated(changedProperties);
|
||||
if (changedProperties.has("_entityId")) {
|
||||
if (changedProperties.has("_entityId") || !this.hasUpdated) {
|
||||
this._setupTodoElement();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user