MCPcopy Create free account
hub / github.com/error311/FileRise / showResumableDraftBanner

Function showResumableDraftBanner

public/js/upload.js:355–433  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

353
354// Show a small banner if there is any in-progress resumable upload for this folder
355function showResumableDraftBanner() {
356 const uploadCard = document.getElementById('uploadCard');
357 if (!uploadCard) return;
358
359 // Remove any existing banner first
360 const existing = document.getElementById('resumableDraftBanner');
361 if (existing && existing.parentNode) {
362 existing.parentNode.removeChild(existing);
363 }
364
365 const { drafts } = getUserDraftContext();
366 const folder = window.currentFolder || 'root';
367
368 const candidates = Object.values(drafts)
369 .filter(d =>
370 d &&
371 d.folder === folder &&
372 typeof d.lastPercent === 'number' &&
373 d.lastPercent > 0 &&
374 d.lastPercent < 100
375 )
376 .sort((a, b) => (b.updatedAt || 0) - (a.updatedAt || 0));
377
378 if (!candidates.length) {
379 return; // nothing to show
380 }
381
382 const latest = candidates[0];
383 const count = candidates.length;
384
385 const countText =
386 count === 1
387 ? 'You have a partially uploaded file'
388 : `You have ${count} partially uploaded files. Latest:`;
389 const resumeHint =
390 count === 1
391 ? 'Choose it again from your device to resume.'
392 : 'Choose them again from your device to resume.';
393 const dismissHint = 'Dismiss clears the partial uploads and temporary files.';
394 const cleanupIds = candidates
395 .map(entry => entry && entry.identifier)
396 .filter(Boolean);
397
398 const banner = document.createElement('div');
399 banner.id = 'resumableDraftBanner';
400 banner.className = 'upload-resume-banner';
401 banner.innerHTML = `
402 <div class="upload-resume-banner-inner">
403 <span class="material-icons" style="vertical-align:middle;margin-right:6px;">cloud_upload</span>
404 <span class="upload-resume-text">
405 ${countText}
406 <strong class="upload-resume-name">${escapeHTML(latest.fileName)}</strong>
407 (~${latest.lastPercent}%).
408 ${resumeHint}
409 ${dismissHint}
410 </span>
411 <button type="button" class="upload-resume-dismiss-btn">Dismiss</button>
412 </div>

Callers 2

initResumableUploadFunction · 0.85
initUploadFunction · 0.85

Calls 4

getUserDraftContextFunction · 0.85
escapeHTMLFunction · 0.85

Tested by

no test coverage detected