Allow opening conversation dialog via URL (#14868)

* Allow opening conversation dialog via URL

* Update URL
This commit is contained in:
Paulus Schoutsen 2022-12-23 20:37:58 -05:00 committed by GitHub
parent 3199319830
commit 526c34993c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,9 +38,11 @@ import { fireEvent } from "../../common/dom/fire_event";
import scrollToTarget from "../../common/dom/scroll-to-target";
import { shouldHandleRequestSelectedEvent } from "../../common/mwc/handle-request-selected-event";
import { navigate } from "../../common/navigate";
import { constructUrlCurrentPath } from "../../common/url/construct-url";
import {
addSearchParam,
extractSearchParam,
extractSearchParamsObject,
removeSearchParam,
} from "../../common/url/search-params";
import { computeRTLDirection } from "../../common/util/compute_rtl";
import { debounce } from "../../common/util/debounce";
@ -556,8 +558,16 @@ class HUIRoot extends LitElement {
protected firstUpdated() {
// Check for requested edit mode
if (extractSearchParam("edit") === "1") {
const searchParams = extractSearchParamsObject();
if (searchParams.edit === "1") {
this.lovelace!.setEditMode(true);
} else if (searchParams.conversation === "1") {
showVoiceCommandDialog(this);
window.history.replaceState(
null,
"",
constructUrlCurrentPath(removeSearchParam("conversation"))
);
}
}