fix(downloads): live-refresh the storage bar so a finished edit/download shows immediately

The 'Your storage' footprint used a one-shot query, refetched only at enqueue time — when the job
is still queued (0 bytes) and the file lands asynchronously via the worker. So the footprint stayed
stale (0 B) until a manual reload. Switch the UsageBar to useLiveQuery(2s), like the library list,
so the footprint updates in lockstep the moment a clip/download completes (and after a delete).
This commit is contained in:
npeter83 2026-07-04 05:30:43 +02:00
parent 1e3fad9a8f
commit 4493501d10

View file

@ -191,7 +191,10 @@ function RenameModal({ job, onClose }: { job: DownloadJob; onClose: () => void }
function UsageBar() { function UsageBar() {
const { t } = useTranslation(); const { t } = useTranslation();
const usage = useQuery({ queryKey: ["download-usage"], queryFn: api.downloadUsage }); // Poll live (like the library list) so the footprint updates the moment the worker finishes an
// edit/download — enqueue only creates a queued job (0 bytes), the size lands asynchronously, so
// a one-shot fetch at enqueue time would show a stale 0 B until a manual reload.
const usage = useLiveQuery(["download-usage"], api.downloadUsage, { intervalMs: 2000 });
const u = usage.data; const u = usage.data;
if (!u) return null; if (!u) return null;
const pct = u.unlimited || !u.max_bytes ? 0 : Math.min(100, (u.footprint_bytes / u.max_bytes) * 100); const pct = u.unlimited || !u.max_bytes ? 0 : Math.min(100, (u.footprint_bytes / u.max_bytes) * 100);