Skip to content

Commit

Permalink
Partially disable browser cache on updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Jan 12, 2025
1 parent 953880b commit b35685f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion custom_components/browser_mod/browser_mod.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion custom_components/browser_mod/browser_mod_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ function e(e,t,i,o){var s,n=arguments.length,r=n<3?t:null===o?o=Object.getOwnPro
display: flex;
align-items: center;
}
`}}e([le()],_e.prototype,"hass",void 0),e([de()],_e.prototype,"_dashboards",void 0),e([de()],_e.prototype,"_editSidebar",void 0),customElements.define("browser-mod-frontend-settings-card",_e);var fe="2.3.2";(async()=>{var e,t,i,o,s,n,r,a,l,d,h,c,u,p,g;await customElements.whenDefined("partial-panel-resolver");const w=document.createElement("partial-panel-resolver")._getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==w?void 0:w.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t)),await customElements.whenDefined("ha-panel-config");const v=document.createElement("ha-panel-config");await(null===(r=null===(n=null===(s=null===(o=null==v?void 0:v.routerOptions)||void 0===o?void 0:o.routes)||void 0===s?void 0:s.dashboard)||void 0===n?void 0:n.load)||void 0===r?void 0:r.call(n)),await(null===(h=null===(d=null===(l=null===(a=null==v?void 0:v.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.general)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await(null===(g=null===(p=null===(u=null===(c=null==v?void 0:v.routerOptions)||void 0===c?void 0:c.routes)||void 0===u?void 0:u.entities)||void 0===p?void 0:p.load)||void 0===g?void 0:g.call(p)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends se{firstUpdated(){window.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){var e;return window.browser_mod?M`
`}}e([le()],_e.prototype,"hass",void 0),e([de()],_e.prototype,"_dashboards",void 0),e([de()],_e.prototype,"_editSidebar",void 0),customElements.define("browser-mod-frontend-settings-card",_e);var fe="2.3.3";(async()=>{var e,t,i,o,s,n,r,a,l,d,h,c,u,p,g;await customElements.whenDefined("partial-panel-resolver");const w=document.createElement("partial-panel-resolver")._getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==w?void 0:w.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t)),await customElements.whenDefined("ha-panel-config");const v=document.createElement("ha-panel-config");await(null===(r=null===(n=null===(s=null===(o=null==v?void 0:v.routerOptions)||void 0===o?void 0:o.routes)||void 0===s?void 0:s.dashboard)||void 0===n?void 0:n.load)||void 0===r?void 0:r.call(n)),await(null===(h=null===(d=null===(l=null===(a=null==v?void 0:v.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.general)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await(null===(g=null===(p=null===(u=null===(c=null==v?void 0:v.routerOptions)||void 0===c?void 0:c.routes)||void 0===u?void 0:u.entities)||void 0===p?void 0:p.load)||void 0===g?void 0:g.call(p)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends se{firstUpdated(){window.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){var e;return window.browser_mod?M`
<ha-top-app-bar-fixed>
<ha-menu-button
slot="navigationIcon"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/browser_mod/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"documentation": "https://github.com/thomasloven/hass-browser_mod/blob/master/README.md",
"iot_class": "local_push",
"requirements": [],
"version": "2.3.2"
"version": "2.3.3"
}
19 changes: 14 additions & 5 deletions custom_components/browser_mod/mod_view.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json
from homeassistant.core import HomeAssistant
from homeassistant.components.frontend import add_extra_js_url, async_register_built_in_panel
from homeassistant.components.http import StaticPathConfig

Expand All @@ -7,8 +9,14 @@

_LOGGER = logging.getLogger(__name__)

def get_version(hass: HomeAssistant):
with open(hass.config.path("custom_components/browser_mod/manifest.json"), "r") as fp:
manifest = json.load(fp)
return manifest["version"]

async def async_setup_view(hass):
async def async_setup_view(hass: HomeAssistant):

version = await hass.async_add_executor_job(get_version, hass)

# Serve the Browser Mod controller and add it as extra_module_url
await hass.http.async_register_static_paths(
Expand All @@ -20,7 +28,7 @@ async def async_setup_view(hass):
)
]
)
add_extra_js_url(hass, FRONTEND_SCRIPT_URL)
add_extra_js_url(hass, FRONTEND_SCRIPT_URL + "?" + version)

# Serve the Browser Mod Settings panel and register it as a panel
await hass.http.async_register_static_paths(
Expand All @@ -42,7 +50,7 @@ async def async_setup_view(hass):
config={
"_panel_custom": {
"name": "browser-mod-panel",
"js_url": SETTINGS_PANEL_URL,
"js_url": SETTINGS_PANEL_URL + "?" + version,
}
},
)
Expand All @@ -69,7 +77,7 @@ async def async_setup_view(hass):
await resources.async_create_item(
{
"res_type": "module",
"url": FRONTEND_SCRIPT_URL + "?automatically-added",
"url": FRONTEND_SCRIPT_URL + "?automatically-added" + "&" + version,
}
)
elif getattr(resources, "data", None) and getattr(
Expand All @@ -78,6 +86,7 @@ async def async_setup_view(hass):
resources.data.append(
{
"type": "module",
"url": FRONTEND_SCRIPT_URL + "?automatically-added",
"url": FRONTEND_SCRIPT_URL + "?automatically-added" + "&" + version,

}
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "browser_mod",
"private": true,
"version": "2.3.2",
"version": "2.3.3",
"description": "",
"scripts": {
"build": "rollup -c",
Expand Down

0 comments on commit b35685f

Please sign in to comment.