From c501d88c63cb601eeae103eef962fae1cb399928 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Mon, 25 May 2026 01:13:19 -0400 Subject: [PATCH] Auto refresh library after ingest --- services/web-ui/public/screens-library.jsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/services/web-ui/public/screens-library.jsx b/services/web-ui/public/screens-library.jsx index 064968c..9c38a6d 100644 --- a/services/web-ui/public/screens-library.jsx +++ b/services/web-ui/public/screens-library.jsx @@ -60,26 +60,22 @@ function Library({ navigate, onOpenAsset, openProject, onClearProject }) { const [projVersion, setProjVersion] = React.useState(0); const refreshAssets = React.useCallback(() => { - window.ZAMPP_API.fetch('/assets?limit=500') - .then(r => { - const list = Array.isArray(r) ? r : (r.assets || []); - const proj = {}; - (window.ZAMPP_DATA?.PROJECTS || []).forEach(p => { proj[p.id] = p.name; }); - const normalized = list.map(a => window.normalizeAsset ? window.normalizeAsset(a, proj) : a); - window.ZAMPP_DATA.ASSETS = normalized; + window.ZAMPP_API.refreshAssets() + .then(function(normalized) { setAllAssets(normalized); }) .catch(() => {}); }, []); // Auto-refresh: poll the library while it's open so live recordings flip - // to 'ready' (with thumbnail) without a manual reload. Speed up while - // anything is mid-flight so the operator sees the transition right away. + // to 'ready' (with thumbnail) without a manual reload. Also pull once on + // mount so uploads/imports created on other screens appear immediately. const hasLive = React.useMemo( - () => allAssets.some(a => a.status === 'live' || a.status === 'processing'), + () => allAssets.some(a => a.status === 'live' || a.status === 'processing' || a.status === 'ingesting'), [allAssets] ); React.useEffect(() => { + refreshAssets(); const tick = hasLive ? 4000 : 15000; const id = setInterval(refreshAssets, tick); const onAssetsChanged = () => refreshAssets();