( map: Record<string, T>, folder: NoteFolder, sourceSubpath: string, targetSubpath: string )
| 736 | } |
| 737 | |
| 738 | function duplicateFolderKeyMap<T>( |
| 739 | map: Record<string, T>, |
| 740 | folder: NoteFolder, |
| 741 | sourceSubpath: string, |
| 742 | targetSubpath: string |
| 743 | ): Record<string, T> { |
| 744 | const next: Record<string, T> = { ...map } |
| 745 | const exactKey = folderIconKey(folder, sourceSubpath) |
| 746 | const prefix = `${exactKey}/` |
| 747 | for (const [key, value] of Object.entries(map)) { |
| 748 | if (key === exactKey) { |
| 749 | next[folderIconKey(folder, targetSubpath)] = value |
| 750 | continue |
| 751 | } |
| 752 | if (key.startsWith(prefix)) { |
| 753 | next[folderIconKey(folder, targetSubpath) + key.slice(exactKey.length)] = value |
| 754 | } |
| 755 | } |
| 756 | return next |
| 757 | } |
| 758 | |
| 759 | export function rewriteFolderColorsForRename( |
| 760 | folderColors: Record<string, FolderColorId>, |
no test coverage detected