(folder)
| 1308 | Fetch children (lazy) |
| 1309 | ----------------------*/ |
| 1310 | async 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 | } |
| 1340 | async function loadMoreChildren(folder, ulEl, moreLi) { |
| 1341 | const cached = await _childCache.get(folder); |
| 1342 | const cursor = cached?.nextCursor || null; |
no test coverage detected