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

Function loadMoreChildren

public/js/folderManager.js:1340–1382  ·  view source on GitHub ↗
(folder, ulEl, moreLi)

Source from the content-addressed store, hash-verified

1338 return p;
1339}
1340async function loadMoreChildren(folder, ulEl, moreLi) {
1341 const cached = await _childCache.get(folder);
1342 const cursor = cached?.nextCursor || null;
1343
1344 const qs = new URLSearchParams({ folder });
1345 if (cursor) qs.set('cursor', cursor);
1346 qs.set('limit', String(PAGE_LIMIT));
1347 qs.set('probe', '0');
1348
1349 const res = await fetch(`/api/folder/listChildren.php?${qs.toString()}`, { method: 'GET', credentials: 'include' });
1350 const body = await safeJson(res);
1351
1352 const raw = Array.isArray(body.items) ? body.items : [];
1353 const newItems = raw
1354 .map(normalizeItem)
1355 .filter(Boolean)
1356 .filter(it => {
1357 const s = it.name.toLowerCase();
1358 return s !== 'trash' && s !== 'profile_pics' &&
1359 !s.startsWith('resumable_');
1360 });
1361
1362 const nextCursor = body.nextCursor ?? null;
1363
1364 newItems.forEach(it => {
1365 const li = makeChildLi(folder, it);
1366 ulEl.insertBefore(li, moreLi);
1367 const full = (folder === 'root') ? it.name : `${folder}/${it.name}`;
1368 try { applyFolderColorToOption(full, (window.folderColorMap||{})[full] || ''); } catch (e) {}
1369 ensureFolderIcon(full);
1370 });
1371
1372 const merged = (cached?.items || []).concat(newItems);
1373 if (nextCursor) _childCache.set(folder, { items: merged, nextCursor });
1374 else {
1375 moreLi.remove();
1376 _childCache.set(folder, { items: merged, nextCursor: null });
1377 }
1378
1379 primeChildToggles(ulEl);
1380 const hasKids = !!ulEl.querySelector(':scope > li.folder-item');
1381 updateToggleForOption(folder, hasKids);
1382}
1383async function ensureChildrenLoaded(folder, ulEl) {
1384 let cached = _childCache.get(folder);
1385 if (cached && typeof cached.then === 'function') {

Callers 1

ensureChildrenLoadedFunction · 0.85

Calls 8

makeChildLiFunction · 0.85
applyFolderColorToOptionFunction · 0.85
ensureFolderIconFunction · 0.85
primeChildTogglesFunction · 0.85
updateToggleForOptionFunction · 0.85
setMethod · 0.80
safeJsonFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected