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

Function findBestAccessibleFolder

public/js/fileListView.js:4415–4437  ·  view source on GitHub ↗
({ lastOpenedFolder, sourceId = '' } = {})

Source from the content-addressed store, hash-verified

4413}
4414
4415async function findBestAccessibleFolder({ lastOpenedFolder, sourceId = '' } = {}) {
4416 try {
4417 const sourceParam = sourceId ? `&sourceId=${encodeURIComponent(sourceId)}` : '';
4418 const res = await fetch(withBase(`/api/folder/getFolderList.php?counts=0${sourceParam}`), { credentials: 'include' });
4419 const data = await safeJson(res);
4420 const names = Array.isArray(data)
4421 ? data.map(row => normalizeFolderPath(row?.folder || row)).filter(Boolean)
4422 : [];
4423 if (!names.length) return null;
4424
4425 const unique = Array.from(new Set(names));
4426 const preferred = normalizeFolderPath(lastOpenedFolder);
4427 if (preferred && unique.includes(preferred)) return preferred;
4428
4429 unique.sort((a, b) => {
4430 const depthDiff = folderDepthScore(a) - folderDepthScore(b);
4431 return depthDiff !== 0 ? depthDiff : a.localeCompare(b);
4432 });
4433 return unique[0] || null;
4434 } catch (e) {
4435 return null;
4436 }
4437}
4438
4439// --- Folder capabilities + owner cache ----------------------
4440const _folderCapsCache = window.__FR_CAPS_CACHE || new Map();

Callers 1

loadFileListFunction · 0.85

Calls 4

withBaseFunction · 0.85
folderDepthScoreFunction · 0.85
safeJsonFunction · 0.70
normalizeFolderPathFunction · 0.70

Tested by

no test coverage detected