fix: realtime subfolder discovery, count updates, and deep level scan indicator
This commit is contained in:
@@ -620,10 +620,20 @@ function Catalogue() {
|
||||
const shape = progress.dirs.length ? `${progress.dirs.length}:${progress.dirs[progress.dirs.length - 1].id}` : '';
|
||||
if (shape !== drew) {
|
||||
drew = shape;
|
||||
// The names of a reading kept to one folder are the folders under that
|
||||
// one and no others: the column keeps what it has, and the rows it
|
||||
// already drew stay where they are.
|
||||
if (!progress.from) setDirs(progress.dirs);
|
||||
if (progress.dirs.length) {
|
||||
setDirs((prev) => {
|
||||
const map = new Map(prev.map((d) => [normPath(d.id).toLowerCase(), d]));
|
||||
let changed = false;
|
||||
for (const d of progress.dirs) {
|
||||
const k = normPath(d.id).toLowerCase();
|
||||
if (!map.has(k)) {
|
||||
map.set(k, d);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed ? [...map.values()] : prev;
|
||||
});
|
||||
}
|
||||
}
|
||||
// A window beside the reading is handed the progress of another build, which
|
||||
// may have no such count: the frames it has stored are then read back on a
|
||||
@@ -1031,7 +1041,9 @@ function Catalogue() {
|
||||
const { hits, foldersUnder } = baseTreeInfo;
|
||||
const counted = (key: string, hit: number | undefined) => {
|
||||
const normKey = (key || '').replace(/\\/g, '/');
|
||||
return Math.max(hit ?? 0, read?.[normKey] ?? read?.[key] ?? 0);
|
||||
const lowerKey = normKey.toLowerCase();
|
||||
const readVal = read?.[normKey] ?? read?.[lowerKey] ?? read?.[key] ?? 0;
|
||||
return Math.max(hit ?? 0, readVal);
|
||||
};
|
||||
const out: Node[] = [];
|
||||
for (const folder of folders) {
|
||||
@@ -1110,6 +1122,25 @@ function Catalogue() {
|
||||
return nKey === mOwn || mOwn.startsWith(`${nKey}/`);
|
||||
};
|
||||
|
||||
// Auto-expand parent folders of the active scan path so deep subfolders (levels 4, 5, 6, 7+)
|
||||
// are visible in the tree while being scanned.
|
||||
useEffect(() => {
|
||||
if (!liveMark) return;
|
||||
const parts = normPath(liveMark.own).split('/');
|
||||
if (parts.length <= 1) return;
|
||||
const toExpand: string[] = [];
|
||||
for (let i = 1; i < parts.length; i++) {
|
||||
toExpand.push(parts.slice(0, i).join('/'));
|
||||
}
|
||||
setExpanded((prev) => {
|
||||
const missing = toExpand.filter((k) => !prev.has(k));
|
||||
if (!missing.length) return prev;
|
||||
const next = new Set(prev);
|
||||
for (const k of missing) next.add(k);
|
||||
return next;
|
||||
});
|
||||
}, [liveMark?.own]);
|
||||
|
||||
// A remembered subfolder that no longer holds a frame falls back to the folder
|
||||
// it sits in, so the screen never opens on a node that is not drawn.
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user