diff --git a/web/kanban.js b/web/kanban.js index 66a22d5..95a4824 100644 --- a/web/kanban.js +++ b/web/kanban.js @@ -626,7 +626,14 @@ async function syncFolder(force=false){ FOLDER.busy=true; try{ if(stages)await makeStageFolders(); - const held=stages?[...new Set([...FOLDER.saved.values()].filter(r=>!r.review).map(r=>r.order).filter(Boolean))].slice(-1000):[]; + // The server answers for up to 1000 orders a pass: the ones still in the + // flow first, then those in Finalizado. A file whose order was not asked + // this time stays as it is; only an order the server says is gone, + // cancelled or moved changes its files. + const records=[...FOLDER.saved.values()].filter(r=>!r.review&&r.order); + const held=stages?[...new Set([...records.filter(r=>r.folder!==STAGE_FOLDERS.fin),...records.filter(r=>r.folder===STAGE_FOLDERS.fin)] + .map(r=>r.order))].slice(0,1000):[]; + const asked=new Set(held); const {files,states,receipts=[],reviews=[]}=await api('/queue/folder',{early:stages,held,since:stages?FOLDER.since||await folderSince():null}); // By file: an item longer than a part (10 m) is several parts (item 13), each its own file. const wanted=new Map(files.map(f=>[f.upload_id,f])); @@ -642,7 +649,7 @@ async function syncFolder(force=false){ ...(folder===STAGE_FOLDERS.fin?{at:file.at||Date.now()}:{})}); FOLDER.last=new Date();await keepSaved();}; if(stages)for(const [uid,rec] of [...FOLDER.saved])await step(rec.name,async()=>{ - if(!rec.order||!rec.folder)return; + if(!rec.order||!rec.folder||!asked.has(rec.order))return; const state=states[rec.order], target=STAGE_FOLDERS[state]; const now=wanted.get(uid); const replaced=(state==='rec'||state==='tra')&&(!now||now.order!==rec.order);