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

Function fetchChildrenOnce

public/js/folderManager.js:1310–1339  ·  view source on GitHub ↗
(folder)

Source from the content-addressed store, hash-verified

1308 Fetch children (lazy)
1309----------------------*/
1310async function fetchChildrenOnce(folder) {
1311 if (_childCache.has(folder)) return _childCache.get(folder);
1312 const qs = new URLSearchParams({ folder });
1313 qs.set('limit', String(PAGE_LIMIT));
1314 qs.set('probe', '0');
1315 const p = (async () => {
1316 const res = await fetch(`/api/folder/listChildren.php?${qs.toString()}`, { method: 'GET', credentials: 'include' });
1317 const body = await safeJson(res);
1318
1319 const raw = Array.isArray(body.items) ? body.items : [];
1320 const items = raw
1321 .map(normalizeItem)
1322 .filter(Boolean)
1323 .filter(it => {
1324 const s = it.name.toLowerCase();
1325 return (
1326 s !== 'trash' &&
1327 s !== 'profile_pics' &&
1328 !s.startsWith('resumable_')
1329 );
1330 });
1331
1332 const payload = { items, nextCursor: body.nextCursor ?? null };
1333 // Replace the promise with the resolved payload for future callers
1334 _childCache.set(folder, payload);
1335 return payload;
1336 })();
1337 _childCache.set(folder, p);
1338 return p;
1339}
1340async function loadMoreChildren(folder, ulEl, moreLi) {
1341 const cached = await _childCache.get(folder);
1342 const cursor = cached?.nextCursor || null;

Callers 5

peekHasFoldersFunction · 0.85
hasUnlockedDescendantFunction · 0.85
chooseInitialFolderFunction · 0.85
ensureChildrenLoadedFunction · 0.85

Calls 3

setMethod · 0.80
safeJsonFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected