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

Function navigateToSearchResult

public/js/fileListView.js:5603–5670  ·  view source on GitHub ↗
(folder, name, sourceId)

Source from the content-addressed store, hash-verified

5601}
5602
5603async function navigateToSearchResult(folder, name, sourceId) {
5604 if (!folder) return;
5605 closeSearchEverywhereModal();
5606 const dest = decodeHtmlEntities(folder || 'root') || 'root';
5607 const targetName = decodeHtmlEntities(name || '');
5608 const targetSourceId = String(sourceId || '').trim();
5609 const activeSourceId = getGlobalActiveSourceId();
5610
5611 if (targetSourceId && targetSourceId !== activeSourceId) {
5612 let applied = false;
5613 if (typeof window.__frApplyActiveSource === 'function') {
5614 try {
5615 applied = await window.__frApplyActiveSource(targetSourceId, { skipEvent: true, origin: 'search' });
5616 } catch (e) { /* ignore */ }
5617 }
5618 if (!applied) {
5619 const sel = document.getElementById('sourceSelector');
5620 if (sel) sel.value = targetSourceId;
5621 try { localStorage.setItem('fr_active_source', targetSourceId); } catch (e) { /* ignore */ }
5622 }
5623
5624 const activePane = normalizePaneKey(window.activePane);
5625 resetPagingForFolderNavigation(activePane);
5626 savePaneState(activePane, {
5627 sourceId: targetSourceId,
5628 currentFolderCaps: null,
5629 selectedFolderCaps: null
5630 });
5631 refreshSourceBadges();
5632 try { resetFolderTreeCaches(); } catch (e) { /* ignore */ }
5633 __frTreeSourceId = targetSourceId;
5634
5635 pendingSearchSelection = targetName ? { folder: dest, name: targetName } : null;
5636 try { await loadFolderTree(dest); } catch (e) { /* ignore */ }
5637
5638 setTimeout(() => maybeHighlightSearchedFile(dest), 80);
5639 setTimeout(() => maybeHighlightSearchedFile(dest), 220);
5640 setTimeout(() => maybeHighlightSearchedFile(dest), 500);
5641 return;
5642 }
5643
5644 pendingSearchSelection = targetName ? { folder: dest, name: targetName } : null;
5645 setCurrentFolderContext(dest, { resetPage: true });
5646
5647 // Refresh tree + strip selections to match the jumped folder
5648 try {
5649 await expandTreePathAsync(dest, { force: true, includeLeaf: true, persist: false });
5650 document.querySelectorAll(".folder-option.selected")
5651 .forEach(o => o.classList.remove("selected"));
5652 const treeNode = document.querySelector(`.folder-option[data-folder="${CSS.escape(dest)}"]`);
5653 if (treeNode) treeNode.classList.add("selected");
5654 } catch (e) { /* best effort */ }
5655
5656 try {
5657 const strip = document.getElementById("folderStripContainer");
5658 if (strip) {
5659 strip.querySelectorAll(".folder-item.selected").forEach(i => i.classList.remove("selected"));
5660 const stripItem = strip.querySelector(`.folder-item[data-folder="${CSS.escape(dest)}"]`);

Callers 2

navigateToLinkedFileFunction · 0.85

Calls 13

decodeHtmlEntitiesFunction · 0.85
getGlobalActiveSourceIdFunction · 0.85
normalizePaneKeyFunction · 0.85
savePaneStateFunction · 0.85
refreshSourceBadgesFunction · 0.85
resetFolderTreeCachesFunction · 0.85
loadFolderTreeFunction · 0.85
setCurrentFolderContextFunction · 0.85
expandTreePathAsyncFunction · 0.85

Tested by

no test coverage detected