( folderIcons: Record<string, FolderIconId>, folder: NoteFolder, oldSubpath: string, newSubpath: string )
| 992 | } |
| 993 | |
| 994 | function 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 | |
| 1017 | function removeFolderIcons( |
| 1018 | folderIcons: Record<string, FolderIconId>, |
no test coverage detected