Skip to content
This repository was archived by the owner on Oct 8, 2020. It is now read-only.

Commit 50efa8d

Browse files
committed
fix settings menu option, typo, wait for hass
1 parent 94c1f54 commit 50efa8d

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

src/config.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export class CustomHeaderConfig {
1818
...lovelace.config.custom_header,
1919
};
2020
this.template_vars = this.config.template_variables;
21-
this.last_template_result = null;
2221
this.test_config = { ...this.config, ...conditionalConfig(this.config, ha_elements()) };
2322
this.template_failed = false;
2423
this.disabled =

src/custom-header.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const rebuild = () => {
107107
return;
108108
}
109109

110-
window['last_template_result'] = [];
110+
window['last_template_result'] = {};
111111
clearTimeout(window['customHeaderTempTimeout']);
112112
if (!window.location.href.includes('disable_ch')) hideHeader(haElem);
113113

src/ha-elements.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { getLovelace } from 'custom-card-helpers';
22

3-
export const hass = document.querySelector('home-assistant').shadowRoot.querySelector('home-assistant-main').hass;
3+
const getHass = () => {
4+
if (document.querySelector('home-assistant').shadowRoot.querySelector('home-assistant-main').hass) {
5+
return document.querySelector('home-assistant').shadowRoot.querySelector('home-assistant-main').hass;
6+
} else {
7+
setTimeout(getHass, 300);
8+
}
9+
};
10+
11+
const hassElem = getHass();
12+
13+
export const hass = hassElem;
414

515
export const ha_elements = () => {
616
const haElem = {};

src/menu-observers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const menuButtonObservers = (config, ch, haElem) => {
9595
if (prevDot && prevDot.style.cssText != buildDot().style.cssText) {
9696
prevDot.remove();
9797
if (config.button_text.menu) {
98-
header.menu.shadowRoot.querySelector('.buttonText').style.textDecoration = '';
98+
ch.header.menu.shadowRoot.querySelector('.buttonText').style.textDecoration = '';
9999
}
100100
}
101101
if (!ch.header.menu.shadowRoot.querySelector('.dot') && haElem.menu.shadowRoot.querySelector('.dot')) {

src/overflow-menu.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,11 @@ export const insertSettings = (header, config, haElem) => {
100100
chSettings.setAttribute('onClick', ' ');
101101
chSettings.innerHTML = 'Custom Header';
102102
if (header.options.querySelector('mwc-list-item') && !header.options.querySelector('#ch_settings')) {
103-
const mwcItems = header.options.querySelectorAll('mwc-list-item');
104-
const mwcItemsHA = header.options.querySelectorAll('mwc-list-item');
105103
if (!header.options.querySelector('#ch_settings')) {
106-
insertAfter(chSettings, mwcItems[mwcItems.length - 1]);
104+
header.options.appendChild(chSettings);
107105
}
108106
if (!haElem.options.querySelector('#ch_settings')) {
109-
insertAfter(chSettings, mwcItemsHA[mwcItemsHA.length - 1]);
107+
haElem.options.appendChild(chSettings);
110108
}
111109
} else if (
112110
header.options.querySelector('paper-listbox') &&

src/style-header.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const styleHeader = (config, ch, haElem = ha_elements()) => {
1717
config.disabled_mode = false;
1818
} else if (!config.hide_ch_settings) {
1919
insertSettings(ch.header, config, haElem);
20-
insertSettings(ch.header, config, haElem);
2120
}
2221

2322
if (config.disabled_mode) {

0 commit comments

Comments
 (0)