( folderColors: Record<string, FolderColorId>, folder: NoteFolder, oldSubpath: string, newSubpath: string )
| 1030 | } |
| 1031 | |
| 1032 | function rewriteFolderColorsForRename( |
| 1033 | folderColors: Record<string, FolderColorId>, |
| 1034 | folder: NoteFolder, |
| 1035 | oldSubpath: string, |
| 1036 | newSubpath: string |
| 1037 | ): Record<string, FolderColorId> { |
| 1038 | const next: Record<string, FolderColorId> = {} |
| 1039 | const exactKey = folderIconKey(folder, oldSubpath) |
| 1040 | const prefix = `${exactKey}/` |
| 1041 | for (const [key, value] of Object.entries(folderColors)) { |
| 1042 | if (key === exactKey) { |
| 1043 | next[folderIconKey(folder, newSubpath)] = value |
| 1044 | continue |
| 1045 | } |
| 1046 | if (key.startsWith(prefix)) { |
| 1047 | next[folderIconKey(folder, newSubpath) + key.slice(exactKey.length)] = value |
| 1048 | continue |
| 1049 | } |
| 1050 | next[key] = value |
| 1051 | } |
| 1052 | return next |
| 1053 | } |
| 1054 | |
| 1055 | function removeFolderColors( |
| 1056 | folderColors: Record<string, FolderColorId>, |
no test coverage detected