Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
wait for config
Browse files Browse the repository at this point in the history
  • Loading branch information
maykar authored Nov 18, 2020
1 parent cd7ffbd commit 78b95f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kiosk-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ const ha = document.querySelector("home-assistant");
const main = ha.shadowRoot.querySelector("home-assistant-main").shadowRoot;
const panel = main.querySelector("partial-panel-resolver");
const drawerLayout = main.querySelector("app-drawer-layout");
let llAttempts = 0;

function getConfig() {
const ll = main.querySelector("ha-panel-lovelace");
if (ll && (!ll.lovelace || !ll.lovelace.config) && llAttempts < 10) {
llAttempts++
setTimeout(() => getConfig(), 50)
}
return ll && ll.lovelace.config.kiosk_mode ? ll.lovelace.config.kiosk_mode : {};
}

Expand Down Expand Up @@ -55,6 +60,7 @@ function kiosk_mode() {
let hide_sidebar = cacheAsBool("kmSidebar") || locIncludes(["kiosk", "hide_sidebar"]);

const config = getConfig();
llAttempts = 0;
const adminConf = config.admin_settings;
const nonAdminConf = config.non_admin_settings;
let userConf = config.user_settings;
Expand Down

0 comments on commit 78b95f3

Please sign in to comment.