Skip to content

Commit

Permalink
Use add_extra_js_url helper to register URL (#3447)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Jan 12, 2024
1 parent 94e66ed commit 2d62d1b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions custom_components/hacs/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
locate_dir as experimental_locate_dir,
)

try:
from homeassistant.components.frontend import add_extra_js_url
except ImportError:

def add_extra_js_url(hass: HomeAssistant, url: str, es5: bool = False) -> None:
hacs: HacsBase = hass.data.get(DOMAIN)
hacs.log.error("Could not import add_extra_js_url from frontend.")
if "frontend_extra_module_url" not in hass.data:
hass.data["frontend_extra_module_url"] = set()
hass.data["frontend_extra_module_url"].add(url)


if TYPE_CHECKING:
from .base import HacsBase

Expand Down Expand Up @@ -45,9 +57,7 @@ def async_register_frontend(hass: HomeAssistant, hacs: HacsBase) -> None:
hass.http.register_static_path(
f"{URL_BASE}/iconset.js", str(hacs.integration_dir / "iconset.js")
)
if "frontend_extra_module_url" not in hass.data:
hass.data["frontend_extra_module_url"] = set()
hass.data["frontend_extra_module_url"].add(f"{URL_BASE}/iconset.js")
add_extra_js_url(hass, f"{URL_BASE}/iconset.js")

hacs.frontend_version = (
FE_VERSION if not hacs.configuration.experimental else EXPERIMENTAL_FE_VERSION
Expand Down

0 comments on commit 2d62d1b

Please sign in to comment.