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

Function refreshFileList

public/js/upload.js:1686–1764  ·  view source on GitHub ↗
(allFiles, uploadResults, progressElements)

Source from the content-addressed store, hash-verified

1684 });
1685
1686 function refreshFileList(allFiles, uploadResults, progressElements) {
1687 const hadFolderPaths = hasFolderPaths(allFiles);
1688 const transferSucceeded = Array.isArray(uploadResults)
1689 ? uploadResults.filter(Boolean).length
1690 : 0;
1691 loadFileList(folderToUse)
1692 .then(serverFiles => {
1693 initFileActions();
1694 // Be tolerant to API shapes: string or object with name/fileName/filename
1695 serverFiles = (serverFiles || [])
1696 .map(item => {
1697 if (typeof item === 'string') return item;
1698 const n = item?.name ?? item?.fileName ?? item?.filename ?? '';
1699 return String(n);
1700 })
1701 .map(s => s.trim().toLowerCase())
1702 .filter(Boolean);
1703
1704 let overallSuccess = true;
1705 let succeeded = 0;
1706
1707 allFiles.forEach(file => {
1708 const clientFileName = file.name.trim().toLowerCase();
1709 const li = progressElements[file.uploadIndex];
1710 const hadRelative = !!(file.webkitRelativePath || file.customRelativePath);
1711
1712 if (!uploadResults[file.uploadIndex] ||
1713 (!hadRelative && !serverFiles.includes(clientFileName))) {
1714 if (li && li.progressBar) {
1715 li.progressBar.innerText = "Error";
1716 }
1717 overallSuccess = false;
1718 } else if (li) {
1719 succeeded++;
1720
1721 // Schedule removal of successful file entry after 5 seconds.
1722 setTimeout(() => {
1723 li.remove();
1724 delete progressElements[file.uploadIndex];
1725 updateFileInfoCount();
1726 const pc = document.getElementById("uploadProgressContainer");
1727 if (pc && pc.querySelectorAll("li.upload-progress-item").length === 0) {
1728 const fi = document.getElementById("file");
1729 if (fi) fi.value = "";
1730 pc.innerHTML = "";
1731 adjustFolderHelpExpansionClosed();
1732 const fic = document.getElementById("fileInfoContainer");
1733 if (fic) {
1734 fic.innerHTML = `<span id="fileInfoDefault">No files selected</span>`;
1735 }
1736 const dropArea = document.getElementById("uploadDropArea");
1737 if (dropArea) setDropAreaDefault();
1738 window.selectedFiles = [];
1739 }
1740 }, 5000);
1741 }
1742 });
1743

Callers 1

submitFilesFunction · 0.85

Calls 12

hasFolderPathsFunction · 0.85
loadFileListFunction · 0.85
initFileActionsFunction · 0.85
updateFileInfoCountFunction · 0.85
setDropAreaDefaultFunction · 0.85
tFunction · 0.85
setUploadButtonVisibleFunction · 0.85
refreshFolderIconFunction · 0.85
hideVirusScanNoticeFunction · 0.85
showToastFunction · 0.70

Tested by

no test coverage detected