mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Added konduktor settings menu
This commit is contained in:
1 parent
40630ff78e
commit
2c352b76a1
5 files changed
+185
-14
No files matched your search
@@ -20,3 +20,26 @@ export function nodeIdsUnder(node: PlaylistNode): Set<string> {
|
||||
walk(node)
|
||||
return ids
|
||||
}
|
||||
|
||||
/** The node with this id, anywhere in the tree. */
|
||||
export function findNode(nodes: PlaylistNode[], id: string): PlaylistNode | undefined {
|
||||
for (const n of nodes) {
|
||||
if (n.id === id) return n
|
||||
const found = findNode(n.children, id)
|
||||
if (found) return found
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** Old id → new id for a node and everything nested in it, after a rename or
|
||||
* move that may have changed them (a platform addressing folders by path).
|
||||
* Neither changes a subtree's shape, so the two are matched by position. */
|
||||
export function idsAfter(before: PlaylistNode, after: PlaylistNode): Map<string, string> {
|
||||
const map = new Map<string, string>()
|
||||
const walk = (a: PlaylistNode, b: PlaylistNode) => {
|
||||
map.set(a.id, b.id)
|
||||
a.children.forEach((c, i) => b.children[i] && walk(c, b.children[i]))
|
||||
}
|
||||
walk(before, after)
|
||||
return map
|
||||
}
|
||||
Reference in new issue
Block a user