used cached values. and poll javascript allow failed polls
This commit is contained in:
@@ -158,7 +158,7 @@ def _safe_get(device_manager, dotpath: str):
|
||||
obj = device_manager.devices
|
||||
for part in dotpath.split("."):
|
||||
obj = getattr(obj, part)
|
||||
return obj.get()
|
||||
return obj.get(cached=True)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
@@ -2230,16 +2230,23 @@ function render(d){{
|
||||
handleAudioForStatus(s, prevStatus);
|
||||
}}
|
||||
|
||||
let _fetchFailCount=0;
|
||||
const FETCH_FAIL_THRESHOLD=3;
|
||||
|
||||
async function poll(){{
|
||||
try{{
|
||||
const r=await fetch(STATUS_JSON, {{cache:'no-store'}});
|
||||
if(!r.ok) throw new Error('HTTP '+r.status);
|
||||
_fetchFailCount=0;
|
||||
render(await r.json());
|
||||
}}catch(e){{
|
||||
console.warn('Fetch failed:',e);
|
||||
document.getElementById('last-update').textContent='fetch failed - retrying...';
|
||||
document.getElementById('outdated-banner').classList.add('visible');
|
||||
handleStale(true);
|
||||
_fetchFailCount++;
|
||||
console.warn('Fetch failed:',e,'('+_fetchFailCount+')');
|
||||
document.getElementById('last-update').textContent='fetch failed - retrying\u2026 ('+_fetchFailCount+')';
|
||||
if(_fetchFailCount>=FETCH_FAIL_THRESHOLD){{
|
||||
document.getElementById('outdated-banner').classList.add('visible');
|
||||
handleStale(true);
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user