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

Function attachStripIconAsync

public/js/fileListView.js:4345–4381  ·  view source on GitHub ↗
(hostEl, fullPath, size = 28, { preserveKind = false, sourceId = '', skipStats = false } = {})

Source from the content-addressed store, hash-verified

4343
4344// Paint initial icon, then flip to "paper" if non-empty
4345function attachStripIconAsync(hostEl, fullPath, size = 28, { preserveKind = false, sourceId = '', skipStats = false } = {}) {
4346 _applyFolderColors(hostEl, fullPath);
4347
4348 const iconSpan = hostEl.querySelector('.folder-svg');
4349 if (!iconSpan) return;
4350 const renderSeq = _stampFolderIcon(iconSpan);
4351
4352 const encrypted = isEncryptedForFolderIcon(fullPath);
4353
4354 // 1) initial icon
4355 const currentKind = iconSpan.dataset.kind || 'empty';
4356 const firstKind = preserveKind ? currentKind : 'empty';
4357 iconSpan.dataset.kind = firstKind;
4358 iconSpan.innerHTML = folderSVG(firstKind, { encrypted });
4359
4360 // make sure this brand-new SVG is sized correctly
4361 try { syncFolderIconSizeToRowHeight(); } catch (e) {}
4362
4363 if (skipStats) return;
4364
4365 const resolvedSource = sourceId || getActivePaneSourceId();
4366 fetchFolderStats(fullPath, resolvedSource)
4367 .then(stats => {
4368 if (!iconSpan.isConnected) return;
4369 if (iconSpan.dataset.renderSeq && iconSpan.dataset.renderSeq !== renderSeq) return;
4370 if (!stats) return;
4371 const folders = Number.isFinite(stats.folders) ? stats.folders : 0;
4372 const files = Number.isFinite(stats.files) ? stats.files : 0;
4373
4374 if ((folders + files) > 0 && iconSpan.dataset.kind !== 'paper') {
4375 iconSpan.dataset.kind = 'paper';
4376 iconSpan.innerHTML = folderSVG('paper', { encrypted });
4377 try { syncFolderIconSizeToRowHeight(); } catch (e) {}
4378 }
4379 })
4380 .catch(() => {});
4381}
4382
4383/* -----------------------------
4384 Helper: robust JSON handling

Callers 4

fileListView.jsFile · 0.85
wireFolderStripItemsFunction · 0.85
repairBlankFolderIconsFunction · 0.85
injectInlineFolderRowsFunction · 0.85

Calls 7

_applyFolderColorsFunction · 0.85
_stampFolderIconFunction · 0.85
isEncryptedForFolderIconFunction · 0.85
folderSVGFunction · 0.85
fetchFolderStatsFunction · 0.85
getActivePaneSourceIdFunction · 0.70

Tested by

no test coverage detected