fix: upload manager — URL imports, active count, board reset

1. URL imports now participate in upload manager pipeline:
   addUrlJob() creates a job row, uploadComplete/setFailed called
   on success/failure — consistent with local file uploads

2. activeCount only counts uploading/processing jobs, not failed.
   Failed jobs no longer inflate the "Uploads (n)" header count.

3. uploadManager.clear() called on boardId change so stale jobs
   from a previous board don't linger in the next board's panel.
This commit is contained in:
Hiren Kangad
2026-03-10 19:10:14 +05:30
parent 784554e40d
commit c126885e53
3 changed files with 39 additions and 3 deletions
+8
View File
@@ -119,14 +119,22 @@ export function setupDragDrop(
const world = viewport.toWorld(e.clientX - rect.left, e.clientY - rect.top);
const placeholder = createPlaceholder(viewport, world.x, world.y);
// Derive a filename from the URL for the upload manager
const urlFilename = url.split('/').pop()?.split('?')[0] || 'url-import';
const isVideoUrl = /\.(mp4|webm|mov)(\?|$)/i.test(url);
const jobId = uploads?.addUrlJob(urlFilename, isVideoUrl ? 'video' : 'image');
try {
const res = await uploadImageFromUrl(boardId, url);
removePlaceholder(viewport, placeholder);
const { id } = handleUploadResult(res, viewport, sceneManager, world.x, world.y, onChange);
selection?.selectOnly(id);
const imgData = res.data.image || res.data;
if (jobId) uploads?.uploadComplete(jobId, imgData.id);
} catch (err: any) {
console.error('URL image upload failed:', err);
removePlaceholder(viewport, placeholder);
if (jobId) uploads?.setFailed(jobId, err.response?.data?.error || err.message || 'URL import failed');
}
}
return;