MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / duplicateFolderIcons

Function duplicateFolderIcons

packages/app-core/src/lib/vault-layout.ts:676–695  ·  view source on GitHub ↗
(
  folderIcons: Record<string, FolderIconId>,
  folder: NoteFolder,
  sourceSubpath: string,
  targetSubpath: string
)

Source from the content-addressed store, hash-verified

674}
675
676export function duplicateFolderIcons(
677 folderIcons: Record<string, FolderIconId>,
678 folder: NoteFolder,
679 sourceSubpath: string,
680 targetSubpath: string
681): Record<string, FolderIconId> {
682 const next: Record<string, FolderIconId> = { ...folderIcons }
683 const exactKey = folderIconKey(folder, sourceSubpath)
684 const prefix = `${exactKey}/`
685 for (const [key, value] of Object.entries(folderIcons)) {
686 if (key === exactKey) {
687 next[folderIconKey(folder, targetSubpath)] = value
688 continue
689 }
690 if (key.startsWith(prefix)) {
691 next[folderIconKey(folder, targetSubpath) + key.slice(exactKey.length)] = value
692 }
693 }
694 return next
695}
696
697// Folder color maps share the exact key scheme as folder icons (`folder:subpath`),
698// so renames/deletes/duplicates rewrite them identically. Generic helpers keep

Callers 1

store.tsFile · 0.90

Calls 1

folderIconKeyFunction · 0.70

Tested by

no test coverage detected