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

Function renderFileTable

public/js/fileListView.js:7296–7969  ·  view source on GitHub ↗
(folder, container, subfolders, options = {})

Source from the content-addressed store, hash-verified

7294}
7295
7296export async function renderFileTable(folder, container, subfolders, options = {}) {
7297 clearInlineRenameState({ restore: false });
7298 const fileListContent = container || document.getElementById("fileList");
7299 const preserveSelection = options && options.preserveSelection === true;
7300 let preservedSelection = [];
7301 const searchTerm = (window.currentSearchTerm || "").toLowerCase();
7302 const itemsPerPageSetting = parseInt(localStorage.getItem("itemsPerPage") || "50", 10);
7303 const tablePane = getPaneKeyForElement(fileListContent);
7304 const panePaging = getPaneFileListPaging(tablePane);
7305 const serverPagingActive = !!(panePaging && searchTerm === "" && !window.advancedSearchEnabled);
7306 let currentPage = serverPagingActive
7307 ? (Number(panePaging.page) || 1)
7308 : (window.currentPage || 1);
7309 const targetSelection = (pendingSearchSelection && pendingSearchSelection.folder === folder)
7310 ? pendingSearchSelection
7311 : null;
7312
7313 // Files (filtered by search)
7314 let filteredFiles = searchFiles(searchTerm);
7315
7316 // Apply current sort (Modified desc by default for you)
7317 if (!serverPagingActive && Array.isArray(filteredFiles) && filteredFiles.length) {
7318 filteredFiles = [...filteredFiles].sort(compareFilesForSort);
7319 }
7320
7321 // Inline folders: sort once (Explorer-style A→Z)
7322 const subfoldersSourceId = String(window.currentSubfoldersSourceId || '');
7323 const subfoldersFolder = String(window.currentSubfoldersFolder || '');
7324 const paneSourceId = String(getPaneSourceIdForElement(fileListContent) || getActivePaneSourceId() || '');
7325 const subfoldersMatch = subfoldersSourceId === paneSourceId && subfoldersFolder === String(folder || '');
7326 const allSubfolders = (subfoldersMatch && Array.isArray(window.currentSubfolders))
7327 ? window.currentSubfolders
7328 : [];
7329
7330// NEW: sort folders according to current sort order (name / size)
7331const subfoldersSorted = await sortSubfoldersForCurrentOrder(allSubfolders);
7332
7333 if (preserveSelection) {
7334 // Capture after async work so user selections during the wait aren't lost.
7335 preservedSelection = getSelectedFileValuesForList(fileListContent);
7336 }
7337
7338 const totalFiles = filteredFiles.length;
7339 const totalFolders = subfoldersSorted.length;
7340 const totalRows = totalFiles + totalFolders;
7341 const hasFolders = totalFolders > 0;
7342 const folderPagingInServerMode =
7343 serverPagingActive &&
7344 window.showInlineFolders !== false &&
7345 hasFolders;
7346 let totalPages = 1;
7347 let pageFolders = [];
7348 let pageFiles = [];
7349
7350 if (serverPagingActive) {
7351 const totalFilesKnown = Number.isFinite(Number(panePaging.total))
7352 ? Math.max(0, Number(panePaging.total))
7353 : Math.max(0, totalFiles);

Callers 10

toggleAdvancedSearchFunction · 0.85
loadFileListFunction · 0.85
goToCombinedServerPageFunction · 0.85
renderGalleryViewFunction · 0.85
sortFilesFunction · 0.85
fileListView.jsFile · 0.85
initSingleModalOnceFunction · 0.85
initMultiModalOnceFunction · 0.85
initTagSearchFunction · 0.85
auth.jsFile · 0.85

Calls 15

clearInlineRenameStateFunction · 0.85
getPaneKeyForElementFunction · 0.85
getPaneFileListPagingFunction · 0.85
searchFilesFunction · 0.85
parseCursorOffsetFunction · 0.85
getCombinedPageLayoutFunction · 0.85
savePaneStateFunction · 0.85
loadFileListFunction · 0.85
buildFileTableHeaderFunction · 0.85

Tested by

no test coverage detected