| 674 | } |
| 675 | |
| 676 | export 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 |