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

Function migrateExpansionStateOnMove

public/js/folderManager.js:1287–1305  ·  view source on GitHub ↗
(sourceFolder, newPath, ensureOpenParents = [])

Source from the content-addressed store, hash-verified

1285 Expansion state migration on move/rename
1286----------------------*/
1287function migrateExpansionStateOnMove(sourceFolder, newPath, ensureOpenParents = []) {
1288 const st = loadFolderTreeState();
1289 const keys = Object.keys(st);
1290 const next = { ...st };
1291 let changed = false;
1292
1293 for (const k of keys) {
1294 if (k === sourceFolder || k.startsWith(sourceFolder + '/')) {
1295 const suffix = k.slice(sourceFolder.length);
1296 delete next[k];
1297 next[newPath + suffix] = st[k]; // carry same 'block'/'none'
1298 changed = true;
1299 }
1300 }
1301 // keep destination parents open to show the moved node
1302 ensureOpenParents.forEach(p => { if (p) next[p] = 'block'; });
1303
1304 if (changed || ensureOpenParents.length) saveFolderTreeState(next);
1305}
1306
1307/* ----------------------
1308 Fetch children (lazy)

Callers 3

syncTreeAfterFolderMoveFunction · 0.85
renameFolderInlineFunction · 0.85
folderManager.jsFile · 0.85

Calls 2

loadFolderTreeStateFunction · 0.85
saveFolderTreeStateFunction · 0.85

Tested by

no test coverage detected