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

Function rewriteFolderIconsForRename

apps/desktop/src/main/vault.ts:994–1015  ·  view source on GitHub ↗
(
  folderIcons: Record<string, FolderIconId>,
  folder: NoteFolder,
  oldSubpath: string,
  newSubpath: string
)

Source from the content-addressed store, hash-verified

992}
993
994function rewriteFolderIconsForRename(
995 folderIcons: Record<string, FolderIconId>,
996 folder: NoteFolder,
997 oldSubpath: string,
998 newSubpath: string
999): Record<string, FolderIconId> {
1000 const next: Record<string, FolderIconId> = {}
1001 const exactKey = folderIconKey(folder, oldSubpath)
1002 const prefix = `${exactKey}/`
1003 for (const [key, value] of Object.entries(folderIcons)) {
1004 if (key === exactKey) {
1005 next[folderIconKey(folder, newSubpath)] = value
1006 continue
1007 }
1008 if (key.startsWith(prefix)) {
1009 next[folderIconKey(folder, newSubpath) + key.slice(exactKey.length)] = value
1010 continue
1011 }
1012 next[key] = value
1013 }
1014 return next
1015}
1016
1017function removeFolderIcons(
1018 folderIcons: Record<string, FolderIconId>,

Callers 1

renameFolderFunction · 0.70

Calls 1

folderIconKeyFunction · 0.70

Tested by

no test coverage detected