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

Function ensureFolderIcon

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

Source from the content-addressed store, hash-verified

1114 return true;
1115}
1116function ensureFolderIcon(folder) {
1117 if (folder === 'recycle_bin') return; // keep custom recycle icon intact
1118 const opt = document.querySelector(`.folder-option[data-folder="${CSS.escape(folder)}"]`);
1119 if (!opt) return;
1120
1121 setFolderIconForOption(opt, 'empty');
1122 const kidsPromise = peekHasFolders(folder).catch(() => false);
1123 kidsPromise.then(hasKids => {
1124 try { updateToggleForOption(folder, !!hasKids); } catch (e) {}
1125 });
1126
1127 scheduleFolderStatsWork(() => {
1128 Promise.all([
1129 fetchFolderCounts(folder).catch(() => ({ folders: 0, files: 0 })),
1130 kidsPromise
1131 ]).then(([cnt, hasKids]) => {
1132 const folders = Number(cnt?.folders || 0);
1133 const files = Number(cnt?.files || 0);
1134 const hasAny = (folders + files) > 0;
1135
1136 setFolderIconForOption(opt, hasAny ? 'paper' : 'empty');
1137 updateToggleForOption(folder, !!hasKids || folders > 0);
1138 }).catch(() => {});
1139 });
1140}
1141
1142/* ----------------------
1143 Toggle (chevron) helper

Callers 6

refreshFolderIconFunction · 0.85
loadMoreChildrenFunction · 0.85
ensureChildrenLoadedFunction · 0.85
syncTreeAfterFolderMoveFunction · 0.85
selectFolderFunction · 0.85
folderManager.jsFile · 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