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

Function primeChildToggles

public/js/folderManager.js:1455–1481  ·  view source on GitHub ↗
(ulEl)

Source from the content-addressed store, hash-verified

1453 Prime icons/chevrons for a UL
1454----------------------*/
1455function primeChildToggles(ulEl) {
1456 ulEl.querySelectorAll('.folder-option[data-folder]').forEach(opt => {
1457 const f = opt.dataset.folder;
1458 if (f === 'recycle_bin') return;
1459 try { setFolderIconForOption(opt, 'empty'); } catch (e) {}
1460
1461 const kidsPromise = peekHasFolders(f).catch(() => false);
1462 kidsPromise.then(hasKids => {
1463 try { updateToggleForOption(f, !!hasKids); } catch (e) {}
1464 });
1465
1466 scheduleFolderStatsWork(() => {
1467 Promise.all([
1468 fetchFolderCounts(f).catch(() => ({ folders: 0, files: 0 })),
1469 kidsPromise
1470 ]).then(([cnt, hasKids]) => {
1471 const folders = Number(cnt?.folders || 0);
1472 const files = Number(cnt?.files || 0);
1473 const hasAny = (folders + files) > 0;
1474
1475 try { setFolderIconForOption(opt, hasAny ? 'paper' : 'empty'); } catch (e) {}
1476 // IMPORTANT: chevron is true if EITHER we have subfolders (peek) OR counts say so
1477 try { updateToggleForOption(f, !!hasKids || folders > 0); } catch (e) {}
1478 });
1479 });
1480 });
1481}
1482
1483
1484export function openColorFolderModal(folder) {

Callers 5

refreshFolderChildrenFunction · 0.85
loadMoreChildrenFunction · 0.85
ensureChildrenLoadedFunction · 0.85
selectFolderFunction · 0.85
loadFolderTreeFunction · 0.85

Calls 5

setFolderIconForOptionFunction · 0.85
peekHasFoldersFunction · 0.85
updateToggleForOptionFunction · 0.85
scheduleFolderStatsWorkFunction · 0.85
fetchFolderCountsFunction · 0.85

Tested by

no test coverage detected