(sourceFolder, newPath, ensureOpenParents = [])
| 1285 | Expansion state migration on move/rename |
| 1286 | ----------------------*/ |
| 1287 | function 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) |
no test coverage detected