From de895dd7f87fdcb4ed3c2c0f05460393e773592b Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Mon, 25 May 2026 01:08:38 -0400 Subject: [PATCH] Fix library refresh behavior --- services/web-ui/public/data.jsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/services/web-ui/public/data.jsx b/services/web-ui/public/data.jsx index 0e58235..4665441 100644 --- a/services/web-ui/public/data.jsx +++ b/services/web-ui/public/data.jsx @@ -120,6 +120,23 @@ function normalizeJob(j) { }; } +async function refreshAssets() { + const raw = await apiFetch('/assets?limit=500'); + const list = Array.isArray(raw) ? raw : (raw.assets || []); + const projectMap = {}; + (window.ZAMPP_DATA.PROJECTS || []).forEach(function(p) { projectMap[p.id] = p.name; }); + const normalized = list.map(function(a) { return normalizeAsset(a, projectMap); }); + window.ZAMPP_DATA.ASSETS = normalized; + if (window.ZAMPP_DATA.PROJECTS && window.ZAMPP_DATA.PROJECTS.length) { + const counts = {}; + list.forEach(function(a) { if (a.project_id) counts[a.project_id] = (counts[a.project_id] || 0) + 1; }); + window.ZAMPP_DATA.PROJECTS = window.ZAMPP_DATA.PROJECTS.map(function(p) { + return { ...p, assets: counts[p.id] || 0 }; + }); + } + return normalized; +} + async function loadData() { const [projectsR, assetsR, recordersR, jobsR, clusterR, usersR, binsR, meR] = await Promise.allSettled([ apiFetch('/projects'), @@ -251,7 +268,7 @@ async function exportSequenceEDL(sequenceId, filename) { } window.ZAMPP_API = { - fetch: apiFetch, loadData, fmtDuration, fmtSize, fmtRelative, + fetch: apiFetch, loadData, refreshAssets, fmtDuration, fmtSize, fmtRelative, getSequences, createSequence, getSequence, updateSequence, deleteSequence, syncSequenceClips, exportSequenceEDL, };